AMXメーカー86の使用説明書/サービス説明書
ページ先へ移動 of 410
® AM X ™ 86 User's Guide First Printing: November 1, 1990 Last Printing: March 1, 2005 Copyright © 1990 - 2005 KADAK Products Ltd. 206 - 1847 W est Bro adway Avenu e Vancouver, BC, C anada, V.
.
AMX 86 User's Guide K A DAK i TECHNICAL SUPPORT KADAK Products Ltd. is committed to technical support for its software products. Our programs are desi gned to be easil y incorporated in your s ystems and every effo rt has been made to eliminate errors.
ii K A DAK AMX 86 User's Guide Copyright © 1990-2005 by KADAK Products Ltd. All rights reserv ed. No part of this publication may be reproduced, transmitted, transcribed, stored in a retrieval s.
AMX 86 User's Guide K A DAK iii AMX 86 USER'S GUIDE Table of Cont ents Page Section 1: System Descript ion 1. AMX Overview 1 1.1 Introduction ........................................................................................ 1 1.2 Glossary .
iv K A DAK AMX 86 User's Guide AMX 86 USER'S GUIDE Table of Contents (Cont'd.) Page Section 1: System Descript ion (Cont'd.) 6. AMX Se m aphore Ma nager 91 6.1 Introduction ..........................................................
AMX 86 User's Guide K A DAK v AMX 86 USER'S GUIDE Table of Contents (Cont'd.) Page Section 1: System Descript ion (Cont'd.) 12. AMX Link ed List Man ager 139 12.1 Introdu ction ......................................................
vi K A DAK AMX 86 User's Guide AMX 86 USER'S GUIDE Table of Contents (Cont'd.) Page Appendice s A. AMX 86 Reserved Wo rds 347 B. AMX 86 Error Codes 349 C. Configuration Generator Specifications 353 C.1 Introdu ction ....................
AMX Overview K A DAK 1 1. AMX Overview 1.1 Intr oduction The AMX ™ Multitasking Executive provides a simple solution to the complexity of real- time multitasking. AMX supe rvises the orderly e xecution of a set of application program modules called tasks.
2 K A DAK AMX Overview Section Sum ma ry This manual is divided into three sections. Each section is divided into chapters. Section 1 of this manua l describes the AMX Multitasking System and how it is used. Separate chapters ar e provided for each of the AMX managers.
AMX Overview K A DAK 3 1.2 G lo ssary Buffer Pool A collection of data buffers whose use is controlled by the AMX Buffer Man ager. Buffer Pool I d The handle assigned to a buff er pool by AMX for use as a unique buffer pool identifier.
4 K A DAK AMX Overview Interrupt Handler An application procedure called from an ISP root to service an interrupting device. Interrupt Servic e Procedure ( I S P) An AMX or application procedure which is executed in response to an external device interrupt requ est.
AMX Overview K A DAK 5 Message Qu eue An AMX data structure used to manage messages sent to a task mailbox or message exchan g e. A separate mess age queue is provided for ea ch of the four message priorities which a task or message exchan ge can support.
6 K A DAK AMX Overview Task An application procedure which is executed b y AMX in a way which makes it look as though all such procedures are ex ecuting at once. Task Control Block (TCB) A private data str ucture maintained by AMX for each task in the sy stem .
AMX Overview K A DAK 7 1.3 AMX Nomencla ture The following nomenclature has been adopted throu ghout the AMX User's Guide. Processor registers ar e referenced as foll ows: 8-Bit Reg isters AH, AL.
8 K A DAK AMX Overview This page left blank intentionall y ..
General AMX Operation K A DAK 9 2. General AMX Operation 2.1 Introduction to Mult itasking A real-time system is charact erized by the need to respond rapidl y to ev ents occurrin g asynchronousl y in time.
10 K A DAK General AMX Operation Alarm sc anning will like ly be hardware dependent. We will simplify matters by assuming that a scannin g task must examine all digital inputs every 100 ms. The task must be capable o f detecting al arm changes in the digital inputs.
General AMX Operation K A DAK 11 2.2 AMX Oper ation AMX Startup Each AMX-based s y stem consists of the AMX execut ive program and a s et of application tasks and interrupt se rvice procedures. This collection of pro grams resident in the memory o f the mic roprocessor configur ation represents the entire operating sy stem .
12 K A DAK General AMX Operation Contr ol Flow Funct ion c a ll s Int errup ts In it ia l iza t io n Restar t Pr oce dure T ask Sc he dule r Services Start Timer Pr oce dure Int errup t Super vi sor Cloc k Ha ndl er Int errup t Servi ce Pr oce dure Kernel Task Us er AMX Ta s k A Ta s k N Cl ock Figure 2.
General AMX Operation K A DAK 13 The Task Sched u ler Following system initialization, AMX proceeds to its Task Scheduler. The Task Scheduler searches its list of av ailable tasks to de termine the highest priority ta sk capable of execution. Task ex ecution priorities are d etermined b y the s y stem d esigner.
14 K A DAK General AMX Operation The Interru pt Supervisor Tasks execute with the processor inter rupt facility ena bled to permit service of externa l devices. When an ex ternal int errupt occu rs, the t ask is interrupt ed in the manner dictat ed by the processor.
General AMX Operation K A DAK 15 Timing F acilities The AMX Timer Manager provides a Clock Handler and a Kernel Task to provide complete timing control for y our r eal-time application. The AMX Clock Han dler is independent of any particular hard ware configuration.
16 K A DAK General AMX Operation Message Queuing One of the more power ful features of AMX is its ability to queue messages for tasks. The queuing facility permits messages to pile up in a controlled fashion, freein g the I SP, Timer Procedure or task which is sending the messa ge to continue with its appointed function.
General AMX Operation K A DAK 17 2.3 AMX M anag ers AMX provides a set of managers to simplif y ev ent synchronization, resource manipulation and memory allocation. Not all applications will make use of all of the managers. The system designer can de cide which of the AMX managers is best suited for a particular application.
18 K A DAK General AMX Operation The AMX 86 Task Mailbox facility provides a ge neral purpose messag e queuing mechanism f or tasks. This service is not provided by a separa te AMX manager; it is an inherent feature of AMX 86. An y task can hav e up to four private mailboxes in which the task can receiv e AMX messages.
General AMX Operation K A DAK 19 The Circular L ist Manager provides a genera l purpose circular list f acility for maintaining compact lists of 8-bit, 16- bit or 32-bit var iables. Circular lists are particularl y use ful for managing character streams asso ciated with input/output devices.
20 K A DAK General AMX Operation 2.4 S tartin g AMX An AMX operating system consists of AMX, the subset of its managers which y ou choose to use and y our complement of application programs. All of these modules are connected together to form the AMX oper ating system as described in the AMX Tool Guide.
General AMX Operation K A DAK 21 Perm anent Launch In most applica tions, your AMX operating s yste m is resident in ROM or loaded into RAM. AMX is started in real mode and given permanent control o f the processor. An AMX system can be launch ed permanentl y from a main pro gram coded in C as illustrated in the f ollowing example.
22 K A DAK General AMX Operation An AMX sy st em can be launched permanentl y from a startup module coded in assembly language a s illustrated in the f ollowing example. Systems of this type begin execution at the AMX ent ry point AAENTR with the launch parame ter in registe r BX .
General AMX Operation K A DAK 23 Temporary Launch Your AMX operating system can be started, allowed to run for a while and then stopped. This type of operation is called a temporar y launch. The most common application of this ty p e occurs on PC compa tibles.
24 K A DAK General AMX Operation When an AMX system is launched fo r temporary execution, it ex ecutes until one of your application tasks c alls the AMX exit procedure ajexit requesting an orderly shutdown of the AMX s y stem (se e Chapter 3.11). The ajexit caller can re turn two parame ters to the procedure t hat launched AMX.
Application Ta s ks K A DAK 25 3. Application T asks 3.1 T ask Creation The AMX Multitasking Executive provides a simple solution to the comple xity of rea l- time multitasking . AMX supervises the orderly execution of a set of application program modules called tasks.
26 K A DAK Application Ta s ks Tasks which do not receive messages are written as Large or Medium model C functions without formal parameters. Thes e tasks must be started using AMX pr ocedure ajtrig . For this reason, such tasks are called tri gger task s .
Application Ta s ks K A DAK 27 3.2 T ask S tates A task is always in one of the following states: Idl e Ready Run Wait Halt When a task is cr eated, AMX assigns it a Task Contr ol Block and sets it in the idle state. An idle task has no outstanding requests to e xecute pending.
28 K A DAK Application Ta s ks event of interest or timeout occu rs ajtri g - trigger a task ajwai t - wait ajwat m - timed wait ajsen w - send me ssa ge to tas k mailbox and wait f o r ack ajmxwa t -.
Application Ta s ks K A DAK 29 3.3 S tartin g a T ask At startup, AMX initializ es all predefined application tasks into an idle state. Once idle, a task cannot execute until AMX rec eives a directive to start the task. How then does an AMX system get off the ground? Three AMX directi ves are provided t o start a task.
30 K A DAK Application Ta s ks 3.4 T ask Priority Task prior ities are used by the AMX Ta sk Scheduler to dete rmine which task to execute . At all times, the task with the highest pr iority which is capable of execution will run. A task's priority is defined at the time the task is created.
Application Ta s ks K A DAK 31 3.5 T ask Execution AMX starts a task by ma king a FAR procedure call to the task. AMX starts execution of a task at the task start address specified in the task 's definition. The task is started in response to a request for its ex ecution.
32 K A DAK Application Ta s ks 3.6 T ask and Event Synchr onizati o n AMX offers several simple forms of task/ev ent sy nchronization. Using the ajwait call, a task can unconditionally wa it for an event. The event can be task dependent, de vice dependent or time dependent.
Application Ta s ks K A DAK 33 The simple featur es included in the AMX k ernel are au gmented by three powerful mechanisms for event s y n chronization provided by separate AMX mana gers. The Semaphor e Manager provides counting semaphores with queuing and timeout facilities for mutual exclusion and re source manageme nt.
34 K A DAK Application Ta s ks 3.7 T ask T im ing The AMX Clock Handler and Kernel Task act a s a Timer Manager providing timing facilities for use by tasks. I t has been sho wn in Chapter 3.6 that tasks can wait for an event to occ ur with an automatic timeout.
Application Ta s ks K A DAK 35 3.8 Endin g a T ask When a task completes its appointed function, it must relinquish control of the proc essor to AMX. The AMX Task Sc heduler will then g ive control of the processor to the next highest priorit y task ready to execute.
36 K A DAK Application Ta s ks 3.9 Me ssage P a ss i ng AMX supports the passing of a message to a task mailbox or messa ge exchange. Messages can be sent to a task by: Application Tasks Interrupt Ser.
Application Ta s ks K A DAK 37 AMX uses messag e envelopes for pa rameter transmission. AMX gets a free envelope, moves the ca ller's message parameters into it and adds the en velope to the task mailbox or message exchange messa ge queue.
38 K A DAK Application Ta s ks Figure 3.9-1 provides an example of the m anner in which messages are allowed to queue on a message exchange. The s ame message queuing technique is used when messages are sent to a task's private mailboxes within its Task Control Block (TCB).
Application Ta s ks K A DAK 39 In due course the destination task will c ontinue to execute a nd complete its processing of the current messag e, X. Th e destination task will then r equest AMX for a message fr om the message exchange three more times in succession to process messages I, J and K.
40 K A DAK Application Ta s ks It is important to note that a copy of the sender's message paramete rs is sent to the destination task. Once the sender's paramet ers have been copied into the message envelope, the caller is free to r euse the parameter storage if desir ed.
Application Ta s ks K A DAK 41 Message Extension AMX deliver s message s to a task by copying the message from a message envelope to a message frame on the task's stack. AMX also present s an extension t o the application message on the task's stack.
42 K A DAK Application Ta s ks 3.10 Rest art Pr ocedu res The manner in which the operating system begins execution is application dependent. Execution begins in the user domain providing the opportunity for hardware specific and application depe ndent setup prior to the initializa tion of the AMX sy stem.
Application Ta s ks K A DAK 43 Restart Procedures can enable specific d evice interrupts if requir ed. Note that interrupts from a device should not be enabled until the application ISP has been installed and made ready to handle the interruptin g device.
44 K A DAK Application Ta s ks 3.1 1 Exit Pr ocedur es An AMX s y stem can b e shut down in an orderl y fashion b y a task call to procedure ajexit . The manner in which the operating s y stem ends ex ecution is application dependent. For example, hardware interfaces ma y require restoration to their initial states.
Application Ta s ks K A DAK 45 Exit Proce dures execute in the context of the task which issued the ajexit c al l. T he y a re therefore fr ee to use all services no rmally availabl e to tasks. For instanc e, an Exit Procedure could use ajsenw to send a shutdown message to a task and wait for that task to do its shutdown processing.
46 K A DAK Application Ta s ks 3.12 T ask Enhancem ents AMX offers several task enh ancements which, although ra rely used, can occasionall y come in hand y . Thes e enhancements are bri efly summarized below. Task Control Bloc k Extensio n Within a task's Task Control Block, 16 by tes are reserved f or the private use of the task.
Application Ta s ks K A DAK 47 AMX Kernel Task Priori ty The AMX Kernel Task op erates as the hi ghest priority task in your AMX s y stem. Its execution priorit y is z ero.
48 K A DAK Application Ta s ks This page left blank intentionall y ..
Interrupt Service Procedures K A DAK 49 4. Interrupt Serv ice Pr ocedures 4.1 The Pr ocessor Interrupt Faci lity The key to e vent-driven, rea l-time, multitasking systems is the proce ssor's interr upt facility . Tasks execute with the interrupt fac ility enable d permitting the syste m to respond to a real-time event.
50 K A DAK Interrupt Service Procedures When used with the 8086 family of microprocessors, AMX supports the following exception and interrupt sources: Divide error ( DIV or IDIV instr uction) Non-Mask.
Interrupt Service Procedures K A DAK 51 4.2 ISPs for External Interrupts Two types of ISPs exist: nonconforming ISPs and conforming ISPs. Nonconforming ISPs A nonconforming I SP must quickly service the device to remove the interrupting condition. The I SP must preserve all registers which it uses.
52 K A DAK Interrupt Service Procedures If the Inter rupt Handler re quested AMX to initiate or resume execution of some task of higher priority th an the interrupted task, the AMX Int errupt Supervisor suspends the interrupted task and marks it as read y to resume execution at the earliest opportunit y.
Interrupt Service Procedures K A DAK 53 Conform ing ISP Construction The construction of an Interrupt Service Pro cedure (ISP) to servic e an external interrupt is a simple proce ss. The conforming ISP consists of two parts: the ISP root and your I nterrupt Hand ler.
54 K A DAK Interrupt Service Procedures The Interrupt Service Procedure should be cod ed using assembly language if speed of executi on is critical. EXTRN AAINT:FAR EXTRN AAINX:FAR ; DVC_CODE SEGMENT .
Interrupt Service Procedures K A DAK 55 The AMX Interrupt Supervisor, when invoked, switches to an Interrupt Stack provided by you in your System Configuration Module. The AMX Interrupt Supervisor then returns to the application ISP. The ISP must perform all services required by th e device.
56 K A DAK Interrupt Service Procedures 4.3 Nested Interrupt s AMX supports nested interrupts. The AMX Interrupt Supervisor maintains a private nesting le vel indicator. AMX must be inf ormed of the start ( AAINT ) and end ( AAINX ) of each interrupt.
Interrupt Service Procedures K A DAK 57 4.4 ISP /T ask Co mm unication AMX provides a set of service proc edures to ease the communication between tasks and device Interrupt Handlers. Thes e AMX procedures simplif y e vent synchronization and permit para meter passing to ta sks.
58 K A DAK Interrupt Service Procedures Sem aphore Synchr onization The AMX Semaphore Manager provides an ev en more powerful s y n chronization capability . I t p rovides the automatic time out facility and also allows more than one task to wait for the sa me event, with each task de termining its own waiting priorit y .
Interrupt Service Procedures K A DAK 59 Task Triggering An Interrupt Handler can communicate with a task by invoking the task's execution. When an interrupt occurs, the Interrupt Handler issues the ajtrig call to AMX identify ing the task which it wishes to have executed.
60 K A DAK Interrupt Service Procedures 4.5 T ask Error T raps The 80x86 processor automaticall y detects the occurr ence of execut ion errors such as division by zero, arithmetic overflow or an arra y bound violation. These errors, b y their very na ture, must be ha ndled by the application in the context of the task in whic h they occur.
Interrupt Service Procedures K A DAK 61 The task trap handler can be written as a Large or Medium mode l C function with formal parame ters. #include "amx831sd.
62 K A DAK Interrupt Service Procedures Note that the C trap handler receives a structure amxregs passed b y value. If your C compiler does not allow such declarati ons, y ou can use casts to coe rce access to the parameter s on the stack as follows: #include "amx831sd.
Interrupt Service Procedures K A DAK 63 INCLUDE AMX831SD.DEF ;AMX Structure Definitions ; USER_CODE SEGMENT BYTE 'CODE' ; ASSUME CS:USER_CODE ; TDIVERR PROC FAR : Access register structure A.
64 K A DAK Interrupt Service Procedures 4.6 Non-M ask able Interrupt The Intel 80x86 processor and equivalents provide a non-mask able interrupt (NM I). This interrupt cannot be inhibited by software. You have complete control over the non-maskable interrupt ISP.
Interrupt Service Procedures K A DAK 65 4.7 Speci al Interrupts Nonconforming In terrupts In some s y stems the re may be devices which generate interrupts requiring no communication or synchronization with any task in the system. For example, a high- speed scanner can in terrupt the p rocessor when ever new dat a readin gs are avail able.
66 K A DAK Interrupt Service Procedures Shared Inte rrupt Handle rs Occasionall y a si ngle Interrupt Handl er can be used to servic e more than one ident ical device. For example, an Int errupt Handler fo r an as ynchronous serial I/O device (U ART) could be used to service the UART for e ach of several communication lines.
Interrupt Service Procedures K A DAK 67 The two device I SP roots are illustrated below. Each of the I SP roots calls the I nterrupt Handler deviceih p assing it a pointer to a unique, public, device dep endent data structure ( dcbA or dcbB ). Note that most common C compilers add leading underscores to function and variable names declar ed in C.
68 K A DAK Interrupt Service Procedures 4.8 V ector T able Initializ ation The 80x86 processor operating in real mode v ectors to an Interrupt Service Procedure (ISP) directly through its Interrupt Vector Table which, in AMX nomenclature, is simply called the AMX Vector Table.
AMX Ti m i ng Control K A DAK 69 5. AMX Timing Control 5.1 Intr oduction to T iming Facilities Most rea l-time sy stems are charac terized by the need to provide prec ise contro l over the timing of activities. A ha rdware clock provides the timing source; AMX provides the control over its use.
70 K A DAK AMX Ti m i ng Control Calendar Clock The AMX Time/Date Manager provides Y2K compliant time of day calendar support if required. The AMX c alendar clock includes second, minute, hour, da y , month, y ear and day of the week. AMX se rvices are provided t o set and read the calend ar clock.
AMX Ti m i ng Control K A DAK 71 5.2 AMX Clock Handler and Kernel T ask AMX includes a conforming clock I SP root, a Clock H andler and a Kernel Task to provide timing f acilities. Wheneve r a clock interr upt occurs, the clock ISP root calls your application clock I nterrupt Handler to dismiss the hardwa re clock interrupt.
72 K A DAK AMX Ti m i ng Control Clock ISP Implem entation AMX can provide timing facilities only if a hardware clock interrupt is available. For efficienc y , it is recommended that the clock ISP be coded in assembly language as illustrated below.
AMX Ti m i ng Control K A DAK 73 In this exampl e, the clock ISP pointer ( CLKIS P ) must be installed into vector number 33 in the processor Interrupt Vector T able (IVT). AMX service procedure AAIVTW has been used in a Restart Procedure for this purpose.
74 K A DAK AMX Ti m i ng Control It is preferred that the AMX Clock Handler be c alled from a clock ISP coded in assembl y language as in the example alread y provided. However, it is possible to code the clock ISP in C as indica ted in the following e xample.
AMX Ti m i ng Control K A DAK 75 5.3 Inter val T imers and T imer Proce dur es AMX supports any number of application interval timers in a s y stem. The maximum number in a s y stem is defined in your System Config uration Module (see Chapter 14.5 ). A timer must be crea ted by an application be fore it can be use d.
76 K A DAK AMX Ti m i ng Control The AMX service pro cedures which can be called from a Timer Pro cedure include the following: ajtrig AATRIG Start (trigger) a task with no messa ge ajsend AASEND Star.
AMX Ti m i ng Control K A DAK 77 Timer Proce dures can be writte n as Large or Medium mode l C func tions with for mal parame ters. #include "amx831cf.
78 K A DAK AMX Ti m i ng Control The Timer Procedure can be coded in ass embler as a FAR procedure as follows: TMR_CODE SEGMENT BYTE 'CODE' ; ; The Timer Procedure is located in user program.
AMX Ti m i ng Control K A DAK 79 5.4 T ask T im e Slicing AMX provides task time slicing as an option. The AMX system must be configured to include a clock if time slicing is to be possible. Time slice intervals are the n specified as multiples of the AMX sy stem tick.
80 K A DAK AMX Ti m i ng Control Figure 5.4-1 illustrates the allocation of pro cessing time to two tasks, B and C. Task B was created fi rst with a time slice interval of 100 AM X s y st em ticks. Task C was creat ed later with a time slice interval of 50 AMX syste m ticks.
AMX Ti m i ng Control K A DAK 81 Time slicing can be comple tely disabled at any time with a call to AMX proce dure ajtsof . Procedure ajtson can then be used to enable time slicing. Task time slice inte rvals can be dy namically adjusted using AMX procedure ajtslv to fine tune the shared use of the proc essor based on observed effects.
82 K A DAK AMX Ti m i ng Control 5.5 T ime/Date M anager Most real-time sy st ems require the maintenance of a calendar clock. The AMX Time/Date Manage r provides this facility . The Y2K compliant ca lendar clock ma intained by the Time/Date Manager includes second, minute, hour, day, month and y e ar.
AMX Ti m i ng Control K A DAK 83 Operation The Time/Date Manager includes two components: an AM X Restart Procedure and a set of service procedures. If your AMX System Configuration Module enables the Time/Date option, AMX automatica lly calls the Time/Date Restart Proc edure dur ing the launch prior to executing any application Restart Proc edure.
84 K A DAK AMX Ti m i ng Control Time/Da te Structu re The Time/Date Man ager provides time and date in the following form. C structure amxtds is defined in the AMX head er file AMX831SD.H . Assembler structure AMX TDS is defined in the AMX definition file AMX831SD.
AMX Ti m i ng Control K A DAK 85 Time/Date Validit y The century is used as follows. At startup, the Time/Date Restart Proc edure resets the century to 0 to indica te that the initial default time and date are incorr ect. Note that the initial time and da te are va lid; they are just not c orrect.
86 K A DAK AMX Ti m i ng Control The following conditions exist when y our Time/Date Scheduling Pr ocedure is ca lled by the Time/Date Ma nager Interrupts are en abled. All registers ar e free for use. DS,ES DGROUP segment SS:SP AMX Kernel S tack ready for use BP Offset of paramet ers on stack The direction flag is set to forward.
AMX Ti m i ng Control K A DAK 87 Your Time/Date Scheduling Procedure can b e coded in assembly language as a FAR procedure as follows: INCLUDE AMX831SD.
88 K A DAK AMX Ti m i ng Control Time/Date ASCII Formats The Time/Date Manager procedu re ajtdf can be used to format time and date into a n ASCII character string in an y o f several popular formats. The time and date is presented to ajtdf in the standard AMX time /date structure.
AMX Ti m i ng Control K A DAK 89 Figure 5.5-1 describes the format sp ecification by te and the effe ct of each bit in it on the formatting of the time and date .
90 K A DAK AMX Ti m i ng Control This page left blank intentionall y ..
AMX Se m aphore M anager K A DAK 91 6. AMX Semaphore Man ager 6.1 Intr oduction E.W. Dijkstra introduce d two primitive opera tions to resolve two seemingly unrelated problems: mutu ally exclusive access b y tasks to critical r esources and th e synchronization of asynchronousl y occurring activities.
92 K A DAK AMX Se m aphore M anager Your use of the Semaphore Mana ger is optional. If y ou intend to use it, you must indicate so in your System Configuration Module.
AMX Se m aphore M anager K A DAK 93 6.2 Semaphor e Use The Semaphore Manager supports any number of semaphores. Th e maximum number of semaphores in a s y stem is defin ed in your System Configuration Module (see Chapter 14.5). The defined maximum sets an upper limit on the number of actual sem aphores that can be created in your application.
94 K A DAK AMX Se m aphore M anager Counting Sem aphore A counting semaphore is created b y specifying an initial semaphore count greater than or equal to zer o in the call to ajsmcre . When used for mutual ex clusion, the semaphore should be given an initial value of one.
AMX Se m aphore M anager K A DAK 95 Resource Se maphore AMX resource semaphores provide the simplest mechanism for controlling the access to critical resources. Resources ma y include disk files, I/O devi ces, database components, regions of memory , specific word s of memory or any other entity which is considere d to be a resource.
96 K A DAK AMX Se m aphore M anager If the resource does not beco me available within the timeout inter val specifie d by the task, the task will be removed from the resourc e semaphore wait queue and will resume execution with a timeout indica tion.
AMX Se m aphore M anager K A DAK 97 6.3 Semaphor e Applications Mutual E xclusion Assume that three t asks, A, B and C, require sh ared access to a common data st ructure being used to control some process.
98 K A DAK AMX Se m aphore M anager #include "amx831cf.h" /* AMX C Interface Header */ static AMXID daccess; /* Data access semaphore id */ static struct { int dbpar1; /* parameter 1 */ int .
AMX Se m aphore M anager K A DAK 99 Task/Event Sy nchronizat ion A counting semaphore can be used to provide s ynchronization between a task waitin g for an event and a task, ISP or Timer Proc edure in which the ev ent is detected. Th e following exam ple assumes that a device ISP detects the event .
100 K A DAK AMX Se m aphore M anager EXTRN AAINT:FAR ;enter ISP EXTRN AAINX:FAR ;leave ISP EXTRN AASMSIG:FAR ;signal to a semaphore EXTRN _SYNCISP:WORD ;ISP synchronization semaphore id ; ; DVC_CODE S.
AMX Se m aphore M anager K A DAK 101 Resource Nesting Assume that two tasks, A and B, have to share a numeric coproc essor. Furthermore, these two tasks also must share a common librar y pro cedure ncmath which must use the coprocessor.
102 K A DAK AMX Se m aphore M anager #include "amx831cf.h" /* AMX C Interface Header */ static AMXID ncaccess; /* Coprocessor resource */ /* semaphore id */ void cdecl rruser(void) { ajsmcre.
AMX Ev ent Mana ger K A DAK 103 7. AMX Ev ent Manager 7.1 Intr oduction The AMX Event Manager provides the most general form of event s ynchronization offered b y AMX.
104 K A DAK AMX Ev ent Mana ger The AMX Event Manager provides the followin g event management services: ajevcre AAEVCRE Create an event group ajevdel AAEVDEL Delete an event group ajevsig AAEVSIG Sig.
AMX Ev ent Mana ger K A DAK 105 7.2 Event S ynchr onization The AMX Event Manager supports an y number of event groups in a s y stem. Each event group includes 16 event flags. The maximum number of event groups in a syst em is defined in your S y stem Configuration Module (se e Chapter 14.
106 K A DAK AMX Ev ent Mana ger Events are signalled by tasks, I SPs and Timer Proce dures. The e vent is signalled with a call to procedu re ajevsig . The caller specifi es the group id of the event group which contains the pa rticular ev ent. More than one event can be signa lled in a single call to ajevsig .
AMX Ev ent Mana ger K A DAK 107 7.3 Event F lag Appli c ation The following ex ample, coded in C, is provide d to illustrate the use of the AMX Event Manager for event s ynchronization. The example shows two tasks, A and B, which must be s ynchronized to the state of a motor.
108 K A DAK AMX Ev ent Mana ger #include "amx831cf.h" /* AMX C Interface Header */ static AMXID motorgroup; static unsigned char motorstatus; #define MOTORPORT 0x65 /* Motor status port */ #.
AMX Ev ent Mana ger K A DAK 109 void cdecl sttaskA(void) /* Task A */ { /* Wait forever for motor on */ if (ajevwat(motorgroup, MOTORON, MOTORON, 0, 0) == AEROK) { : Motor is on.
110 K A DAK AMX Ev ent Mana ger This page left blank intentionall y ..
AMX Message Exchange Manager K A DAK 111 8. AMX M essag e Exc hange Mana ger 8.1 Intr oduction The AMX Message Exchan ge Manager provides a v ery flexible, general purpose mechanism f or inter proce ss communication and sy nchronization using prioritized messages.
112 K A DAK AMX Message Exchange Manager The task' s wait priority is not to be confused with the message queue prior ity. The message queue prior ity dete rmines the priority orde ring of messag es in the message exchange whe n no task is waiting for a message.
AMX Message Exchange Manager K A DAK 113 8.2 Me ssage Ex change U se The Message Exchange Manager supports an y number of message exchan ges. The maximum numbe r of message exchanges in a system is def ined in your System Configuration Module (see Chapter 14.
114 K A DAK AMX Message Exchange Manager Messages are sent to message exchan ges in AMX message envelopes. The Message Exchange Manager gets a free message envelope from the common pool of envelopes maintained by AMX.
AMX Message Exchange Manager K A DAK 115 8.3 Me ssage Ex change Applic ati on The following example, code d in C, is provided to illustrate the use of the AMX Message Exchange Manager. This example illustrates a solution to the problem posed in the introduction (Chapter 8.
116 K A DAK AMX Message Exchange Manager #include "amx831cf.h /* AMX C Interface Header */ #define UMS 12 /* User message size */ extern AMXID dactid; /* Data acquisition task id */ extern AMXID .
AMX Message Exchange Manager K A DAK 117 void cdecl sttask(void) /* Common task body */ { union msgu msgbuf; /* Message buffer */ int status; /* Wait at priority 0 for */ /* up to 5 sec for message */ status = ajmxwat(msgexch, &msgbuf, ajtmcnv(5000), 0); if (status == AEROK) { : Process the message in msgbuf.
118 K A DAK AMX Message Exchange Manager void cdecl dactask(void) /* Data acquisition task */ { union msgu msgbuf; /* Message buffer */ : Perform data acquisition functions : if (no_error) { : Construct message in msgbuf.
AMX Buffer M anager K A DAK 119 9. AMX Buffer Manage r 9.1 Intr oduction The AMX Buffer Manager simplifies the manage ment of memory buffers in a real-time system. I t provides a general mechanism for the allocation and control o f fixed size buffers.
120 K A DAK AMX Buffer M anager 9.2 Buffer Pool U se The Buffer Manager supports an y number of pools of buffers. The maximum number of buffer pools in a s y stem is defin ed in your System Configuration Module (see Chapter 14.5). The de fined maximum sets an upper limit on the number of actual buffer pools that can be created in your application.
AMX Buffer M anager K A DAK 121 Ge t Buffer Once a buffer pool has be en created, you may call procedure ajbget to get a buf fer from the pool. The Buffer Manager unlinks a buffer from the pool's fre e list, sets the associated buffer use count to one and returns a pointer to the first b y te of the buffe r.
122 K A DAK AMX Buffer M anager 9.3 Buffer Applicat io ns Consider the following example. A process cont rol system using AMX has a printer on which errors and status messa ges are to be logged. These messages are generated by several tasks as they perform their process control functions.
AMX Buffer M anager K A DAK 123 These solutions each h ave their own advantages and disadvantages. Method 1 requires twice as man y buf fers as the other methods and requir es extra processor time to cop y the message twice. Method 2 cannot displa y the messa ge simultaneously on both the CRT and printer.
124 K A DAK AMX Buffer M anager 9.4 Buffer Manager Cave at s Although the B uffer Manager attempts to check as many error conditions as possible, it cannot protect against a bad s y stem design.
AMX M em ory Manage r K A DAK rev9 125 10. AMX M em ory Man a ger 10.1 Int roducti on The AMX Memory Manager simplif ies the manag ement of memory in a n AMX system. It provides a g eneral mecha nism for the dynamic allocation and c ontrol of memor y and is specifically de signed for use in a multitasking environment.
126 K A DAK AMX M em ory Manage r The AMX Memory Manager provides the following memor y management services: ajmget AAMGET Get a block of memor y ajmfre AAMFRE Release a blo ck of memory ajmgsz AAMGSZ.
AMX M em ory Manage r K A DAK 127 10.2 N omencla tur e The following nomenclature has been adopted b y the Memory Manager. A Me mory Section is a contiguous, double word ali gned area of Random Access Memory Random (RAM) which has been specified b y the user to be under the control of the Memor y Manager.
128 K A DAK AMX M em ory Manage r 10.3 M em ory Allocation The Memory Manager maintains a single memor y pool. The memory pool consists of any number of memory sections of varying size s measured in byte s. An y memory section size which is a multiple of 4 and gre ater than or equal to 64 bytes is allowed.
AMX M em ory Manage r K A DAK 129 Use Count When the Memory Manager allocates a bloc k of memory for the use of a task, it sets the block's use count to one. The block owner may call the Memor y Manager procedur e ajmau to increase th e use count.
130 K A DAK AMX M em ory Manage r 10.4 P rivat e Mem ory Alloc ation A particular l y unique fea ture of the Memory Manager permits any bloc k of memor y (including those acquired from the Memor y Manager) to be treated as a memor y section from which smaller private blocks can be d ynamically allocated.
AMX M em ory Manage r K A DAK 131 10.5 M e m ory Ass ignment The sections of memor y which make up the memory pool controlled by the Memor y Manager must be provided b y your application. The Memory Manager makes no assumptions concerning the whereabouts of the memor y over which it has control.
132 K A DAK AMX M em ory Manage r 10.6 M em ory Assignm ent Procedur e An application Memory Assignment Procedure must be provided to d y n amically assign memory sections to the Memor y Manager. The Memory Assignment Procedur e is called by the Memory Manager when AMX is started, p rior to execution of an y of y ou r Restart Procedures.
AMX M em ory Manage r K A DAK 133 Your Memory Assignment Procedure can be coded as a Large or Medium model C procedure with formal paramet ers as follows.
134 K A DAK AMX M em ory Manage r The Memor y Assi gnment Procedure can be coded in assembler as a FAR proc edure. USER_CODE SEGMENT BYTE 'CODE' ; ASSUME CS:USER_CODE ; PUBLIC MEMPROC ; PARA.
AMX Circula r List M anager K A DAK 135 1 1. AMX Circular List Ma nager 1 1.1 Cir c ular L ists The AMX Circular L ist Manager provides a gener al circular list facility for use by application program modules. Circular lists must be located in alte rable memory (RAM).
136 K A DAK AMX Circula r List M anager 1 1.2 Cir cular List Use A circular l ist is created b y an application wit h a call to procedu re ajrstl . The caller must provide three parameters: the number of slots in the lis t, the si z e of each slot (1, 2 or 4 bytes) and a pointer to RAM stora ge for the circular list.
AMX Circula r List M anager K A DAK 137 1 1.3 Ci r cula r List S tructur e Circular lists are applic ation data structures whi ch are only accessible b y calls to the AMX Circula r List Ma nager. The interna l structure of the list is private to the Circular List Manager.
138 K A DAK AMX Circula r List M anager The same lists ca n be coded in assembly language a s follows: USER_DATA SEGMENT WORD 'DATA' ; ; Circular Lists must be in program data ; NSLOT EQU 64.
AMX Linked Li st Manager K A DAK 139 12. AMX Link ed List Manager 12.1 Int roducti on The Linked List Manager provides a ge neral set of fast linked list services suitable for use in real-time systems.
140 K A DAK AMX Linked Li st Manager 12.2 Link ed Lists Terminology A list header is a structure provided b y the application to be used to anchor a list. The list head er is used to identify a list. The conten t of the list header is pr ivate to the Linked List Manager.
AMX Linked Li st Manager K A DAK 141 Figure 12.2-1 illustrates three doubly linked lists of apples and oranges. All apples and oranges reside on a fruit list. Fresh apples or oranges reside on a f resh list. Rotten apples or oranges reside on a rotten list.
142 K A DAK AMX Linked Li st Manager 12.3 Link ed List Use A list consists of a list header and objects linked to the list header b y list nodes (or ke y nodes). Storage for the list header must be provided by y ou. A pointer to the list header acts as the list identifier.
AMX Linked Li st Manager K A DAK 143 The following example code d in C illustrates the use of the Linked List Manager. An object called uobject is defined with a ke y node at offset keynode i n the object. An array of ten objects is provided. A ke y ed list keylist is created and th e ten objects are added to the list in random order.
144 K A DAK AMX Linked Li st Manager void example(void) { int i; struct uobject *objp; /* Object pointer */ int nodeofs; /* Node offset */ nodeofs = (char *)(&objarray[0].keynode) - (char *)&objarray[0]; ajlcre(&keylist, nodeofs); /* Create empty keyed list */ nodeofs = (char *)(&objarray[0].
AMX Linked Li st Manager K A DAK 145 The following ex ample coded in asse mbler illustra tes the use of the Linked List Manager. The example mimics the operation of the previous C implementation. It illustrates the optimization effe cts which can be ac hieved by coding in assembler.
146 K A DAK AMX Linked Li st Manager USER_CODE SEGMENT BYTE 'CODE' ;Code segment ; ASSUME CS:USER_CODE, DS:USER_DATA, ES:USER_DATA ; EXTRN RANDOM:FAR ;Random number generator ; EXAMPLE PROC .
Advanced T opics K A DAK 147 13. Adva nced T opics 13.1 F atal E xit There are a number of conditions which, if encountered b y AMX, are conside red to be fatal. Any attempt b y AMX to continue execution will lead to unpredictable results at best. All of these conditions ca use AMX to force a branch to its fatal exit handler at ajfatl .
148 K A DAK Advanced T opics Fat al Exit Proce dure AMX allows y ou to p rovide a Fatal Exit Procedure of your own by specifying the name of your procedure in y our System Configuration Module (see Chapter 14.5). Whenever AMX or y our applicati on forces a fatal ex it, AMX checks to see if you have provided a Fatal Exit Procedure.
Advanced T opics K A DAK 149 Your Fatal Exit Proce dure can be coded as a Larg e model C procedure as illustrated in the followi ng example. #include "amx831ec.
150 K A DAK Advanced T opics 13.2 U ser Err or Pr ocedur e Most AMX procedures return error status to the caller. The error st atus is a signed integer. AEREROK = 0 No error AERxxx > 0 Warning: possible fault AERxxx < 0 Error: may be unrecov erable The defined erro r codes are summarized in Appendix B.
Advanced T opics K A DAK 151 Your User Error Pro cedure can be coded in assembl y language as a FAR procedure. Upon entry to your User Error Pr ocedure, the following c onditions exist: Interrupts are disabled.
152 K A DAK Advanced T opics 13.3 T ask Scheduling Ho ok s AMX does not provide direct support for sp ecific hardware ex tensions such as a math coprocessor or a memory management unit. Instead, AMX allows a set of application procedures to be connected to its Task Schedul er.
Advanced T opics K A DAK 153 13.4 A bn ormal T ask T erm ination A task is a procedure whic h is called by the AMX Task Scheduler. The t ask ends execution normall y by returning to AMX. AMX provides p rocedu re ajend whi ch can be used by a task to end execution and return t o AMX under circumstances i n which its stack is deepl y nested.
154 K A DAK Advanced T opics Kill a Task A task can be killed. The task is first stopped as just described. All outstanding requests to the task for its e xecution are purge d. The effect is the sa me as if the task continued to make calls to ajend to e nd its operation until fina lly there were no task execution requests re maining.
Advanced T opics K A DAK 155 A Task Termination Procedure can b e coded as a Large or Medium model C procedure as illustrated in the following example. The procedure r eceives an integer reason code indicating whether the task is being stopped, killed or deleted.
156 K A DAK Advanced T opics A Task Termination Procedure can b e coded in assembler as a FAR procedure as indicated in the follo wing example. The procedu re receives an integer reason code i ndicating whether the task is being stopped, killed or deleted.
Advanced T opics K A DAK 157 Term ination Pr ocessing AMX will only stop or kill a task which is running, waiting or ready to execute. A task can be deleted if it is in any of these states or idle . Occasionally, a request to terminate a task will occur while that task is perfor ming some operation whic h AMX deems to be critical.
158 K A DAK Advanced T opics 13.5 T ask Suspend/Resume Some operating s y stems p er mit a task to suspend any task, including itself. This fea ture is then used to implement the equivalent of the AMX task wait procedure ajwait . The ab ility to ar bitrarily suspend a task is one of the most abuse d privileges afford ed by other operating systems.
Advanced T opics K A DAK 159 13.6 Br eak point Man ager The AMX Breakpoint Manager can be used to improve the op eration of th e debugger that you use to test your AMX s y stem. Your use o f the Breakpoint Manager is optional; use it only if it augments your debugger as describ ed below.
160 K A DAK Advanced T opics Using the Break point Manager The Breakpoint Manager is included in your application only if it is enabled in your User Paramete r File. Use the AMX Configur ation Builder to edit y our User Paramete r File (see Chapter 14.
Advanced T opics K A DAK 161 Interrupt Maski ng The Breakpoint Manager must be tailored to inhibit interrupts at breakpoints. Which interrupts are to b e inhibited and how this is done is both s y stem and hardware dependent. When you include the Breakpoint Manager in your AMX s y stem, module AA831BKA.
162 K A DAK Advanced T opics NMI Breakpoi nts Some hardware debuggers ma y use the non-maskable interrupt (NM I) to generate breakpoints. The Breakpoint Manager can be tailored to suppo rt such debu g gers b y enabling its NMI handler.
AMX Sy stem Configura t io n K A DAK 163 14. AMX System Config uration 14.1 System Configuration Module The AMX System Configuration Module defines the cha racteristics of your AMX system. The AMX Configuration Builder, described in Chapter 14.2, will create this module for you.
164 K A DAK AMX Sy stem Configura t io n 14.2 System Configuration Builder The AMX Configuration B uilder is a softw are generation tool which can be used to create your AMX System Configuration Module.
AMX Sy stem Configura t io n K A DAK rev8 165 Sy stem Docum ent ati on Template File AM831CG.CTD Sy stem C onfigurati on Template File AM831CG.CT User Parameter File SYSCFG.UP Config uration Manage r Enter/Edit/View AM X Sy st em Param eter s Config uration Generator SYSCFG.
166 K A DAK AMX Sy stem Configura t io n 14.3 U si ng the Bu ilder Starting t he Builder The AMX Configuration Builder will operate on a PC or compatible running the Microsoft ® Windows ® operating s y stem. The Builder is delivered with the following f iles.
AMX Sy stem Configura t io n K A DAK 167 Screen Layout Figure 14.3-1 illustrates the Configuration Manager ' s screen la y out. Th e title bar identifies the User Para meter File being created or edited. Below the title bar is the me nu bar from which the operations y ou wish the Mana g er to perform can b e selected.
168 rev9 K A DAK AMX Sy stem Configura t io n Menus All commands to the Conf iguration Manag e r are a vailable as items on the menus present on the menu bar. The File menu provides the conventional New , Open , Sa ve and Save As. .. commands f or creating and e diting your User Parame ter File.
AMX Sy stem Configura t io n K A DAK 169 If you have modified some of the fields on a propert y page and then decide that these modified values are not correct, use th e Undo P ag e command on the Edi.
170 K A DAK AMX Sy stem Configura t io n 14.4 Sy stem Parameter Definitio n The System Parameter window allows y ou to define th e general operating parameters of your AMX s y stem.
AMX Sy stem Configura t io n K A DAK 171 AMX Int errupt St ack Size The AMX I nterrupt Supervisor requires a minimum Interrupt Stack size of 128 bytes. The stack size must be a multiple of 4 by t es. In a ddition to this minimum, y ou must a llocate suff icient stack to satisfy the application ISP with the greatest stack usage.
172 K A DAK AMX Sy stem Configura t io n Ti min g O pt io ns Hardware C lock F requency This parameter defines the fr equency of the AMX hardware clock in hertz. I t is used by AMX to convert milliseconds to equivalent AMX system ticks. I f y our hardware clock frequenc y is not integral, round the clock frequen cy to the nearest non-zero integer.
AMX Sy stem Configura t io n K A DAK 173 14.5 AMX Object Alloc ation The AMX Object Allocation window allows you to define the number of private AMX objects required for each o f the optional AMX managers to be included in your s y stem. The layout of the window is shown below.
174 K A DAK AMX Sy stem Configura t io n Ma ximu m N u mber of Se map hor es This parameter defines the max imum number of resource and countin g semaphores which your system can support concurrentl y . If you do not require any semaphores, set this parameter to 0.
AMX Sy stem Configura t io n K A DAK 175 Memory Assignment Procedu re Name If you use the AMX Memor y Man ager, you must provide a Memor y Assignment Procedure to assign memor y sections to its memory pool for allocation to tasks (see Chapter 10.6). This parameter sp ecifies the name of that procedu re.
176 K A DAK AMX Sy stem Configura t io n 14.6 R e st art/Exit Pr ocedur e Definiti on The Launch/Shutdown window displays all of your application Restart and Exit Procedures which will be c alled by AMX at system startup and shutdown. The layout of the window is shown below.
AMX Sy stem Configura t io n K A DAK 177 Add, Edit and De lete R estart and Exit Pr ocedure s To add a new procedure, cli ck on the Add button below the list. A new procedure named ---New--- will a ppear at the bottom of the list. Clic k on the name ---New--- a nd it will be opened rea dy for editing.
178 K A DAK AMX Sy stem Configura t io n 14.7 T ask De finit ion The Task Definition window allows you to define the tasks to be automaticall y created by AMX at sy st em startup. You do not have to predefine all of your tasks in this manner; y ou ma y also cr eate tasks dyna mically using ajtkcre .
AMX Sy stem Configura t io n K A DAK 179 Task Tag Each task can have a unique 4-cha racter task tag. This parameter defines that tag. Although AMX does not restrict the content of the task tag field, the Confi guration Manager only supports 4 ASCII characte rs as a tag.
180 K A DAK AMX Sy stem Configura t io n Medium Model Tasks can be either L a rge or Medium. I f your task is Medium model, check this box. Otherwise, leave this box unchecked.
AMX Sy stem Configura t io n K A DAK 181 14.8 Tim er De fin ition The Timer Definition window allows you to define the timers to be automaticall y created by AMX at system startup. You do not have to predefine all of y our timers in this manner; y ou may also cre ate timers dyna mically using ajtmcre .
182 K A DAK AMX Sy stem Configura t io n Tag Each timer can have a unique 4- character time r tag. This pa rameter defines that tag. Although AMX do es not restrict the content of the timer tag field, the Configuration Manager only supports 4 ASCII characte rs as a tag.
AMX Sy stem Configura t io n K A DAK 183 14.9 Sem aphore D efinit ion The Semaphore Definition window allows you to define the semaphores to be automatically created b y AMX at system startup.
184 K A DAK AMX Sy stem Configura t io n Tag Each semaphore can have a unique 4-charact er semaphore tag. This parameter defin es that tag. Although AMX does not restrict the content of the semaphore tag field, the Configuration Manager only supports 4 ASCII characters as a t ag.
AMX Sy stem Configura t io n K A DAK 185 14.10 E v ent Gr oup Definition The Event Group Definition window allows you to define the event groups to be automatically created b y AMX at system startup. You do not have to predefin e all of your event groups in this manner; you may also create event groups dynamically using ajevcre .
186 K A DAK AMX Sy stem Configura t io n Tag Each event group can have a unique 4-character event group tag. This par ameter defines that tag. Although AMX does not restrict the content of the event group tag field, the Configuration Manager only supports 4 ASCII characters as a t ag.
AMX Sy stem Configura t io n K A DAK 187 14.1 1 Message E xchan ge Def initi on The Message Exchange De finition window allows y o u to define the message exchan ges to be automatically created by AMX at system startup.
188 K A DAK AMX Sy stem Configura t io n Tag Each message exchange can have a unique 4 -character message ex change tag. This parameter defines that tag. Althoug h AMX does not restrict the content of the message exchange tag field, the Confi g uration Manager only supports 4 ASC II characters as a tag.
AMX Sy stem Configura t io n K A DAK 189 14.12 Bu ffer Poo l Defin ition The Buffer Pool Definition window allows you to d efine the buffer pools to be automatically created b y AMX at system startup. You do not have to predefin e all of your buffer pools in this manner; you may also create bu ffer pools d y n amically using ajbcre .
190 K A DAK AMX Sy stem Configura t io n Tag Each buffer pool can have a unique 4-c haracter buffer pool tag. This pa rameter defines that tag. Although AMX does not restrict the content of the buffer pool tag field, the Configuration Manager only supports 4 ASCII characters as a t ag.
AMX Sy stem Configura t io n K A DAK 191 14.13 B reak point Manager Definit i on The AMX Breakpoint Manager can be used to improve the op eration of your debu gger in the AMX multitasking environment. Your use of the Breakpoint Manager is optional. The layout of the window is shown below.
192 K A DAK AMX Sy stem Configura t io n This page left blank intentionall y ..
AMX Service Procedures K A DAK 193 15. AMX Ser vice P r ocedur es 15.1 Int roducti on The AMX Library pr ovides a wide variety of ser vices from which the real-time system designer can choose. Man y of the services are optional and, i f not used, will not even be present in your final AMX system.
194 K A DAK AMX Service Procedures 15.2 Sum m ary of Services AMX provides a wide variety of services from which the real-time system designer can choose. Many of the services are optional and, if not used, will not even be present in your AMX s y stem.
AMX Service Procedures K A DAK 195 Task Control ajend AAEND End task execution ajgmsg AAGMSG Get the hig hest priority message available Optionally ge t a message of a specific priority ajresum AARESU.
196 K A DAK AMX Service Procedures Timing Co ntrol ajclk AACLK AMX Clock Handler ajtick AATICK Read elapsed s y stem ticks ajtmcnv AATMCNV Convert milliseconds to system ticks ajtmcre AATMCRE Create a.
AMX Service Procedures K A DAK 197 Message Exchange Manager ajmxcre AAMXCRE Create a m essage exchange ajmxdel AAMXDEL Delete a messa ge exchange ajmxget AAMXGET Get a message from a messa ge ex chang.
198 K A DAK AMX Service Procedures Circular L ist Manager ajabl AAABL Add to bottom of circular list ajatl AAATL Add to top of circular list ajrbl AARBL Remove from bottom of circular list ajrstl AARS.
AMX Service Procedures K A DAK 199 Processor and C In terface Proced ures In addition to the services provided b y AMX and its managers, the AMX Library includes seve ral C procedure s of a general nature which simplify application programming in real-time systems on your targ et processor.
200 K A DAK AMX Service Procedures AMX 86 PC Supervi sor Service Pr ocedu res In addition to the services provided by AMX and its managers, the AMX 86 PC Supervisor Library includes several C procedures which are of use only if the AMX 86 PC Supervisor is used by your application.
AMX 86 Procedures K A DAK 201 16. AMX 86 Procedures 16.1 Int roducti on A description of every AMX Librar y procedure is provided in this chapte r. The descriptions are ordered alphab etically for eas y reference. Italics are used to distinguish programming examples.
202 K A DAK AMX 86 Procedures Where If the procedure has input par ameters, they will be described narrativel y. Results The outputs produced b y the procedure a re always defined. The sta te of the carr y , parity, auxiliary , zero, sign and overflow flag s are of no consequence when progra mming in C.
AMX 86 Procedures K A DAK 203 Assembly Language Programming If you are programming in assembl y langua g e, refer to Appendix E for a description of the AMX assembly language calling conventions. The appendix includes a summar y of the input and output register specifications for every AM X procedure.
204 K A DAK AMX 86 Procedures FAR pointers are passed to AMX as seg:reg as i n the followin g example. status = ajsenw(taskid, priority, (void FAR *)msg); AX AASEND DX CX[14..0] ES:BX CX[15]=1 Specific bi ts in a register reg are ref erenced using the s yntax reg[bit] or reg[highbit.
AMX 86 Procedures K A DAK 205 ajabl ajabl Purpose Add to B ottom of Circular List Used by n Task n ISP n Time r Proce dure n Restart P roce dure n Exit Proced ure Setup char item; /* one byte item */ int status; . . status = ajabl(&list, item); AX ES:BX CL,CX or DX:CX Where &list is a pointer to a circular list (see ajrstl ).
206 K A DAK AMX 86 Procedures ajatl ajatl Purpose Add to Top of Circular L ist Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup char item; /* one byte item */ int status; . . status = ajatl(&list, item); AX ES:BX CL,CX or DX:CX Where &list is a pointer to a circular list (see ajrstl ).
AMX 86 Procedures K A DAK 207 ajbau ajb au Purpose Add to B uffer's Use Count Used by n Task n ISP n Time r Proce dure n Restart P roce dure n Exit Proced ure Setup int increment; char *buffp; int status; . . status = ajbau(buffp, increment); AX ES:BX DX Where buffp is a pointer to a buffer obtained with an ajbget call.
208 K A DAK AMX 86 Procedures ajbcr e ajbcre Purpose Create a Bu ffer Pool Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup #include "amx831sd.
AMX 86 Procedures K A DAK 209 Results Interrupts a re disabled and then re stored to their sta te at the time of the call. Status is returned. AEROK = C all successful AERNFP = No fre e buffer pool AE.
210 K A DAK AMX 86 Procedures ajbdel ajbdel Purpose Delete a B uffer Pool Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup AMXID poolid; int status; . . status = ajbdel(poolid); AX DX Where poolid is the pool id of the buffer pool to be deleted.
AMX 86 Procedures K A DAK 211 ajbfr e ajbfre Purpose Free a Bu ffer Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup char *buffp; int status; . . status = ajbfre(buffp); AX ES:BX Where buffp is a pointer to a buffer obtained b y an ajbget call.
212 K A DAK AMX 86 Procedures ajbget ajb get Purpose Get a Buffer Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup AMXID poolid; char *buffp; int status; . . status = ajbget(poolid, &buffp); AX DX ES:BX= Where poolid is the pool id of the pool from which the buffer is to be obtained.
AMX 86 Procedures K A DAK 213 ajbgsz ajb gsz Purpose Get Size of Buffer Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup char *buffp; unsigned int size; int status; . . status = ajbgsz(buffp, &size) ; AX ES:BX CX= Where buffp is a pointer to a buffer obtained with an ajbget call.
214 K A DAK AMX 86 Procedures ajbia ajb ia Purpose In itialize (Reset) All Buffer Pools Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup int status; . . status = ajbia(); AX Results Interrupts a re disabled and then re stored to their sta te at the time of the call.
AMX 86 Procedures K A DAK 215 ajbip ajb ip Purpose In itialize (Reset) O ne Buffer Pool Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup AMXID poolid; int status; . . status = ajbip(poolid); AX DX Where poolid is the pool id of the buffer pool to be initialized.
216 K A DAK AMX 86 Procedures ajbtag ajbt ag Purpose Find a Buffer Pool Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup char tag[4]; AMXID poolid; int status; . . status = ajbtag(&poolid, tag); AX DX= [DX:CX] see note Where &poolid is a pointer to storage for the pool id of the buffer pool of interest.
AMX 86 Procedures K A DAK 217 ajcfjlong ajcfj long ajcfjset ajcfjset Purpose ajcfjset Sets a Mark f or a Long Jum p ajcfjlong Long Jumps to that Mark These pr ocedures are provided for AMX portability . They are not replacement s for C library p rocedures longjmp or setjmp although they function in a similar manner.
218 K A DAK AMX 86 Procedures Example #include "AMX831CF.H" void cdecl dowork(struct ajxjbuf *jbp); static struct ajxjbuf jumpbuffer; #define STACKSIZE 512 /* Stack size (longs) */ static lo.
AMX 86 Procedures K A DAK 219 ajcfstk j m p ajcfstk jmp Purpose Switc h Stacks a nd Jump t o a New P rocedure This procedure is provide d for AMX portability. Used by n Task o ISP o Time r Proce dure o Rest art Proced ure n Exit Proce dure Setup Prototy pe is in file AMX831CF.
220 K A DAK AMX 86 Procedures ajclk ajclk Purpose AMX Clock Handler Used by o Task n IS P o T imer Pr oce dure o Rest art Pr oced ure o Exit Proce dure Setup I nterrupts must be disabled. ajclk(); Results Interrupts ma y be enabled and/or disabled and will then be r estored to their state a t the time of the call.
AMX 86 Procedures K A DAK 221 ajdi ajd i ajei aje i Purpose Disable or Enable Interrupts Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup ajdi(); ajei(); Results Interrupts are disabled b y ajdi() or enabled b y ajei() .
222 K A DAK AMX 86 Procedures ajend ajend Purpose End Execution of a Task Used by n Task o ISP o Time r Proce dure o Rest art Proced ure o Exit Proce dure Setup ajend(); Results There is no return from ajend . If a ny task is waiting for this task to finish processing its message, AMX will automatica lly ca ll ajwakc to wake that task.
AMX 86 Procedures K A DAK 223 ajentr ajentr Purpose Launch (Ent er) t he AMX Multit asking System Used by o Task o IS P o Timer Pro cedure o Restar t Pro cedur e o Exit Proced ure Setup #include "amx831sd.h" . . struct amxupts FAR *uptp; int launchparm; char *result; int status; .
224 K A DAK AMX 86 Procedures Results No return unless a task calls ajexit . status = errcode given to ajexit result = 4 by te pa ra meter exitinfo given to ajexit Upon return, interrupts are restored to their state upon entr y to this procedure. Used By Must only b e called by a C main() procedure to start an AMX s y stem.
AMX 86 Procedures K A DAK 225 ajevcr e a je vcre Purpose Create an Event Group Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup AMXID group; unsigned int ivalue; int status; char tag[4]; .
226 K A DAK AMX 86 Procedures ajevdel aje vdel Purpose Delete an Event Grou p Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup AMXID group; int status; . . status = ajevdel(group); AX BX Where group is the group id of an event group acqui red with a call to ajevcre .
AMX 86 Procedures K A DAK 227 ajevnt ajevnt Purpose Get th e Saved Event Flags Used by n Task o ISP o Time r Proce dure o Rest art Proced ure n Exit Proce dure Setup unsigned int value; . . value = ajevnt(); AX Where value is the state of the 16 e vent flags a t the time the calling task most recentl y complet ed a call to ajevwat.
228 K A DAK AMX 86 Procedures ajevrd ajevrd Purpose Read th e Current Even t States in an Ev ent Group Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup AMXID group; unsigned int value; int status; .
AMX 86 Procedures K A DAK 229 ajevsi g ajevsi g Purpose Si gnal Event(s) i n an Event Group Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup AMXID group; unsigned int mask; unsigned int value; int status; .
230 K A DAK AMX 86 Procedures ajevtag ajevtag Purpose Find an Event G roup Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup AMXID group; char tag[4]; int status; .
AMX 86 Procedures K A DAK 231 ajev wat ajev wat Purpose Wait for Event(s) in an Event Group Used by n Task o ISP o Time r Proce dure o Rest art Proced ure n Exit Proce dure Setup AMXID group; unsigned int mask; unsigned int value; int match; long timeout; int status; .
232 K A DAK AMX 86 Procedures Results Interrupts are disabled and then en abled upon return. Status is returned. AEROK = Call successful; eve nt match occu rred AERTMO = Timed out before event match o.
AMX 86 Procedures K A DAK 233 ajexit aje xit Purpose Leave (Exit) the AMX Multitasking System Used by n Task o ISP o Time r Proce dure o Rest art Proced ure o Exit Proce dure Setup char *exitinfo; int errcode; . . ajexit(errcode, exitinfo); CX DX:BX Where errcode is the error code to be returne d to the ajentr caller as status .
234 K A DAK AMX 86 Procedures ajfatl ajfatl Purpose Fatal Exit from AMX Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup int errcode; . . ajfatl(errcode); CX Where errcode is an error code which will be passed to your Fatal Exit Procedure if one was provided in your User Paramet er File.
AMX 86 Procedures K A DAK 235 ajfl agrd, ajflagrddi ajfl agrd, ajflagrddi ajfl agwr ajfl agwr Purpose Read Processo r Flags Read Processor Flags and Disable Interrupts Write Processor Flags Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup unsigned int flags; .
236 K A DAK AMX 86 Procedures ajgms g ajgm sg Purpose Get Message from Task Mailbox Used by n Task o ISP o Time r Proce dure o Rest art Proced ure n Exit Proce dure Setup int priority; char msg[AMXMSZ]; int status; .
AMX 86 Procedures K A DAK 237 ajgofs ajg ofs Purpose Get Pointer Of f set Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup unsigned int ofs; char FAR *pntr; . . ofs = ajgofs(pntr); Results Interrupts are untouched.
238 K A DAK AMX 86 Procedures ajgseg ajg seg Purpose Get Pointer Seg men t Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup unsigned short int seg; char FAR *pntr; . . seg = ajgseg(pntr); Results Interrupts are untouched.
AMX 86 Procedures K A DAK 239 ajgsr eg ajgsr eg Purpose Get Seg ment Registers Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.
240 K A DAK AMX 86 Procedures ajhook ajh ook Purpose Insta ll Task Sche duler Hooks Used by n Task o ISP o Tim er P ro cedur e o Rest art Pr oced ure n Exit Proce dure Setup struct { int (*uhstart)(); int (*uhend)(); int (*uhsuspend)(); int (*uhresume)(); } userhooks; .
AMX 86 Procedures K A DAK 241 ajinb ajinb ajinw aji nw Purpose Re ad an 8-Bit Input P ort (Byte) Read a 16-Bit Input Port (Word) Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup int portno; char portbyte; short int portword; .
242 K A DAK AMX 86 Procedures ajint ajint ajinx ajinx Purpose Begin Interrupt Service Used by o Task n IS P o T imer Pr oce dure o Rest art Pr oced ure o Exit Proce dure Setup ajint(); Results Interrupts are disabled. The AMX Interrupt Supervisor saves all registers on the caller's stack.
AMX 86 Procedures K A DAK 243 ajispm ajispm Purpose Make a Conforming ISP Root This procedure c reates an AMX root ISP per mitting a standard C fun ction to serve as an AMX Interrupt Service Procedu re. Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup #include "amx831sd.
244 K A DAK AMX 86 Procedures ajitrp ajitrp Purpose Install a Task Trap Handler Install a task trap handler to service divide error, overflow or bound check error traps. Used by n Task o ISP o Time r Proce dure o Rest art Proced ure o Exit Proce dure Setup int inttype; void handler(); int status; .
AMX 86 Procedures K A DAK 245 ajivtr ajivtr Purpose Read an Interrupt Vector Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup int inttype; void (*oldproc)(); int status; . . status = ajivtr(inttype, &oldproc); AX DX ES:BX Where inttype is the 8086 interrupt type (0-255).
246 K A DAK AMX 86 Procedures ajivtw aji vtw Purpose Write an Interrupt Vector Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup int inttype; void newproc(); int status; . . status = ajivtw(inttype, newproc); AX DX ES:BX Where inttype is the 8086 interrupt type (0-255).
AMX 86 Procedures K A DAK 247 ajivtx aji vtx Purpose Exch ange an Interrup t Vector Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup int inttype; void (*oldproc)(); void newproc(); int status; .
248 K A DAK AMX 86 Procedures ajlcr e ajlcre Purpose Create an Empty List Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.h" . . struct amxlhs list; int offset; . . ajlcre(&list, offset); DS:SI CX Where &list is a pointer to the list hea der.
AMX 86 Procedures K A DAK 249 ajlhead ajlhead Purpose Find Firs t Object on List Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.h" . . struct amxlhs list; struct appobj *object; . . object = ajlhead(&list); ES:BX DS:SI Where &list is a pointer to the list hea der.
250 K A DAK AMX 86 Procedures ajlinsc ajl insc Purpose In sert Object before Current Obje ct on List Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.h" . . struct amxlhs list; struct appobj *newobj, *curobj; .
AMX 86 Procedures K A DAK 251 ajlinsh ajl insh Purpose Insert Object at Head of List Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.h" . . struct amxlhs list; struct appobj *object; .
252 K A DAK AMX 86 Procedures ajlinsk ajl insk Purpose In sert Object into Keyed List Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.h" . . struct amxlhs list; struct appobj *object; unsigned int key; .
AMX 86 Procedures K A DAK 253 ajlinst ajl inst Purpose Insert O bject at Tail of List Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.h" . . struct amxlhs list; struct appobj *object; .
254 K A DAK AMX 86 Procedures ajlmerg ajlm erg Purpose Merg e Two Lists Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.h" . . struct amxlhs destlist, srclist; struct appobj *destobj, *srcobj; .
AMX 86 Procedures K A DAK 255 Note Assembly la nguage call is: PUSH <segment srcobj> PUSH <offset srcobj> PUSH <segment destobj> PUSH <offset destobj> PUSH <segment scrlist&.
256 K A DAK AMX 86 Procedures ajlnext ajlnext Purpose Find Next Object on List Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx83lsd.h" . . struct amxlhs list; struct appobj *object, *curobj; .
AMX 86 Procedures K A DAK 257 ajlordk ajlordk Purpose Reorder an Object in a Key ed List Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.h" . . struct amxlhs list; struct appobj *object; unsigned int key; .
258 K A DAK AMX 86 Procedures ajlpr ev ajlpr ev Purpose Find Previou s Object on List Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.h" . . struct amxlhs list; struct appobj *object, *curobj; .
AMX 86 Procedures K A DAK 259 ajlrm vc ajlrm vc Purpose Remove Object from List Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.h" . . struct amxlhs list; struct appobj *object; . . ajlrmvc(&list, object); DS:SI ES:BX Where &list is a pointer to the list hea der.
260 K A DAK AMX 86 Procedures ajlrm vh ajlrm vh Purpose Remove Object from Head of List Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.h" . . struct amxlhs list; struct appobj *object; .
AMX 86 Procedures K A DAK 261 ajlrm vt ajlrm vt Purpose Remove Object from Tail of List Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.h" . . struct amxlhs list; struct appobj *object; .
262 K A DAK AMX 86 Procedures ajltail a jltail Purpose Find Last Object on List Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.h" . . struct amxlhs list; struct appobj *object; . . object = ajltail(&list); ES:BX DS:SI Where &list is a pointer to the list hea der.
AMX 86 Procedures K A DAK 263 ajmau ajm au Purpose Add to Memory Block Use Coun t Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup char *blockp; int increment; int status; . . status = ajmau(blockp, increment); AX ES:BX DX Where blockp is a pointer to a memor y block alloc ated by aj mget or ajmgeh .
264 K A DAK AMX 86 Procedures ajmfr e ajmfre Purpose Free Previously Allo cated Block Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup char *blockp; int status; . . status = ajmfre(blockp); AX ES:BX Where blockp is a pointer to a memor y block alloc ated by aj mget or ajmgeh .
AMX 86 Procedures K A DAK 265 ajmgeh ajm g eh Purpose Get a Memory Block Using a Memory Handle Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup long size; char *blockp; long memsize; char *handle; int status; .
266 K A DAK AMX 86 Procedures ajmget ajm g et Purpose Get a Memory Block Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup long size; char *blockp; long memsize; int status; . . status = ajmget(size, &blockp, &memsize); AX DX:CX ES:BX= DX:CX= Where size is the number of b y tes of memory required.
AMX 86 Procedures K A DAK 267 ajmgsz ajm gsz Purpose Get Size of Memory Block Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup char *blockp; long blksize; int status; . . status = ajmgsz(blockp, &blksize); AX ES:BX DX:CX= Where blockp is a pointer to a memor y block alloc ated by aj mget or ajmgeh .
268 K A DAK AMX 86 Procedures ajmh an ajmh an Purpose Creat e Memory Handle f or Private Alloca tion Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup char *blockp; long memsize; char *handle; int status; .
AMX 86 Procedures K A DAK 269 ajmodl ajm odl Purpose Get th e DGROUP Segmen t Value Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup ajmodl(); Results Interrupts are untouched. The data segment re gister DS is set to the base segment of group DGROUP .
270 K A DAK AMX 86 Procedures ajmset ajm s et Purpose Set (Fill) M emory Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup char *mempntr; long memsize; unsigned short int pattern; int status; .
AMX 86 Procedures K A DAK 271 ajmxcr e ajmxcre Purpose Create a Message Exchange Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup AMXID exchange; int mb0, mb1, mb2, mb3; char tag[4]; int status; .
272 K A DAK AMX 86 Procedures ajmxdel ajm xdel Purpose Delete a Message Exchange Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup AMXID exchange; int status; . . status = ajmxdel(exchange); AX BX Where exchange is the exchange id of the messa ge exchange to be deleted.
AMX 86 Procedures K A DAK 273 ajmxget ajm xget Purpose Get a Message fro m a Message Exchange (no wait) Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup AMXID exchange; char msg[AMXMSZ]; int status; .
274 K A DAK AMX 86 Procedures ajmxsnd ajm xsnd Purpose Send Message to Message Exchange Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup AMXID exchange; char msg[AMXMSZ]; int priority; int status; .
AMX 86 Procedures K A DAK 275 ajmxsndp ajm x sndp Purpose Send Message to a Message Exchange Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup AMXID exchange; int priority; int status; int parm1; int parm2; . . status = ajmxsndp(exchange, priority, parm1, parm2.
276 K A DAK AMX 86 Procedures ajmxtag ajmxtag Purpose Find a Message Exchange Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup AMXID exchange; char tag[4]; int status; .
AMX 86 Procedures K A DAK 277 ajmx wat ajmxwat Purpose Wait for a Message from a Message Exchange Used by n Task o ISP o Time r Proce dure o Rest art Proced ure n Exit Proce dure Setup AMXID exchange; char msg[AMXMSZ]; long timeout; unsigned int priority; .
278 K A DAK AMX 86 Procedures ajoutb ajoutb ajout w ajout w Purpose Write to an 8-Bit Output Port (Byte) Write to a 16-Bit Output Port (Word) Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup int portno; char portbyte; short int portword; .
AMX 86 Procedures K A DAK 279 ajpr oc ajproc ajpr ocq a jpr ocq Purpose Call Software Procedure You can use this pro cedure to call any software proc edure which, because of register setup requirem ents, cannot otherwise be called from C. Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.
280 K A DAK AMX 86 Procedures Results Interrupts will be in the state in whic h they are left b y the called procedure when it exits. All reg isters in regarray reflect the values in t he proc essor registe rs at t he time the calle d procedure ended.
AMX 86 Procedures K A DAK 281 ajprvl ajpr vl Purpose Lower Task Privilege Used by n Task o ISP o Time r Proce dure o Rest art Proced ure n Exit Proce dure Setup ajprvl(); Results Interrupts a re disabled and then re stored to their sta te at the time of the call.
282 K A DAK AMX 86 Procedures ajprvr ajpr vr Purpose Raise Task Privilege Used by n Task o ISP o Time r Proce dure o Rest art Proced ure n Exit Proce dure Setup ajprvr(); Results Interrupts a re disabled and then re stored to their sta te at the time of the call.
AMX 86 Procedures K A DAK 283 ajrbl ajrbl Purpose Remove from Bottom of Circular List Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup char item; /* one byte item */ int status; . . status = ajrbl(&list, &item); AX ES:BX CL=, CX= or DX:CX= Where &list is a pointer to a circular list (see ajrstl ).
284 K A DAK AMX 86 Procedures ajre sum a jr esum Purpose Re sume a Suspende d Task Resume a task known to be suspended as a result of an ajsusp call. Used by n Task n ISP n Time r Proce dure o Re start Pro ced ure n Exit Proce dure Setup AMXID taskid; int status; .
AMX 86 Procedures K A DAK 285 ajrstl ajrstl Purpose In itialize (Reset) a Circu lar List Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup /* define type of slots .
286 K A DAK AMX 86 Procedures ajrtl ajrtl Purpose Remove from Top of Circular List Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup char item; /* one byte item */ int status; . . status = ajrtl(&list, &item); AX BX CL=, CX= or DX:CX= Where &list is a pointer to a circular list (see ajrstl ).
AMX 86 Procedures K A DAK 287 ajsend ajsend Purpose Send a Message to a Task Mailbox To request AMX to send a message to a task at a given priorit y and to begin execution of that task as soon as possible.
288 K A DAK AMX 86 Procedures ajsendp ajsendp Purpose Send a Message to a Task Mailbox To request AMX to send a message to a task at a given priorit y and to begin execution of that task as soon as possible.
AMX 86 Procedures K A DAK 289 ajsen w ajsen w Purpose Send a Message to a Task Mailbox (Wait for Ack) To request AMX to send a message to a task at a given priorit y and to begin execution of that task as soon as possible. The task making the request is placed into the wait state until either: 1.
290 K A DAK AMX 86 Procedures Results Interrupts a re disabled and then re stored to their sta te at the time of the call. Status is returned. AEROK = C all successful AERNST = Invalid task id AERNME .
AMX 86 Procedures K A DAK 291 ajsen wp ajsenwp Purpose Send a Message to a Task Mailbox (Wait for Ack) To request AMX to send a message to a task at a given priorit y and to begin execution of that task as soon as possible. The task making the request is placed into the wait state until either: 1.
292 K A DAK AMX 86 Procedures Results Interrupts a re disabled and then re stored to their sta te at the time of the call. Status is returned. AEROK = C all successful AERNST = Invalid task id AERNME .
AMX 86 Procedures K A DAK 293 ajsgnl ajs gnl Purpose Signal a Task Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup AMXID taskid; unsigned int tsignals; unsigned long siginfo; int status; . . status = ajsgnl(taskid, tsignals, &siginfo); AX DX BX[14.
294 K A DAK AMX 86 Procedures Results ( continued) AERTNW = Task was not waiting for any of these sig nals. These signals are now pending for the task. At least one of these signals was alre ady pending impl y i ng a signal overrun. Variable siginfo can be examined to see which signals caused the overrun.
AMX 86 Procedures K A DAK 295 ajsgrd ajsgrd Purpose Rea d Pending Task Signa ls Used by n Task o ISP o Time r Proce dure o Rest art Proced ure n Exit Proce dure Setup unsigned int tsignals; . . tsignals = ajsgrd(); AX Where tsignals is the current sta te of the calling task's task signa ls.
296 K A DAK AMX 86 Procedures ajsgr es ajsgr es Purpose Rese t Pending Task Signa ls Used by n Task o ISP o Time r Proce dure o Rest art Proced ure n Exit Proce dure Setup unsigned int tsignals; . . ajsgres(tsignals); BX[14..0] BX[15]=0 Where tsignals is a 15-bit mask ide ntify ing the task signals to be rese t.
AMX 86 Procedures K A DAK 297 ajsgwa t ajsgwat Purpose Wait for Task Signal(s) Used by n Task o ISP o Time r Proce dure o Rest art Proced ure n Exit Proce dure Setup unsigned int tsignals; long timeout; int match; int status; unsigned int sigrecv; . .
298 K A DAK AMX 86 Procedures Results Interrupts are disabled and then en abled upon return. Status is returned. AEROK = C all successful AERTM0 = Timed out before required signals occurred AERTMV = I.
AMX 86 Procedures K A DAK 299 ajsint ajsint ajsintq ajsintq Purpose Gene rate Software In terrupt Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.h" . . struct amxregs regarray; int inttype; unsigned int regeax: .
300 K A DAK AMX 86 Procedures Results Interrupts will be in the state in which they are left by the interrupt procedure when it ex its. All reg isters in regarray reflect the values in t he proc essor registe rs at t he time the interr upt procedure ended.
AMX 86 Procedures K A DAK 301 ajsmcr e ajsmcr e Purpose Create a S emaphore Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup AMXID semid; int value; char tag[4]; int status; .
302 K A DAK AMX 86 Procedures ajsmdel ajsm del Purpose Delete a S emaphore Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup AMXID semid; int status; . . status = ajsmdel(semid); AX BX Where semid is the semaphore id of a resou rce or counting semaphore acquired by a call to ajsmcre .
AMX 86 Procedures K A DAK 303 ajsmfr e ajsmfr e Purpose Uncond itionally Free a Resour ce Semaphore Used by n Task o ISP o Time r Proce dure o Rest art Proced ure n Exit Proce dure Setup AMXID semid; int status; . . status = ajsmfre(semid); AX BX Where semid is the semaphore id of a resource semaphore acquired by a call to ajsmcre .
304 K A DAK AMX 86 Procedures ajsmget ajsm get Purpose Get Use of a Semaphore (no wait) Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup AMXID semid; int status; . . status = ajsmget(semid); AX BX Where semid is the semaphore id of a countin g semaphore acquired by a call to ajsmcre .
AMX 86 Procedures K A DAK 305 ajsmrl s ajsmrl s Purpose Release a R esource Semaphore Used by n Task o ISP o Time r Proce dure o Rest art Proced ure n Exit Proce dure Setup AMXID semid; int status; . . status = ajsmrls(semid); /* nested release */ AX BX Where semid is the semaphore id of a resource semaphore acquired by a call to ajsmcre .
306 K A DAK AMX 86 Procedures ajsmrs v ajsmrs v Purpose Reserv e a Resource Semaph ore Used by n Task o ISP o Time r Proce dure o Rest art Proced ure n Exit Proce dure Setup AMXID semid; long timeout; unsigned int priority; int status; .
AMX 86 Procedures K A DAK 307 Results Interrupts are disabled and then en abled upon return. Status is returned. AEROK = C all successful AERNSS = Invalid semaphore id AERTMO = Timed out without being.
308 K A DAK AMX 86 Procedures ajsmsi g ajsm sig Purpose Signal a Se maphor e Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup AMXID semid; int status; . . status = ajsmsig(semid); AX BX Where semid is the semaphore id of a countin g semaphore acquired by a call to ajsmcre .
AMX 86 Procedures K A DAK 309 ajsmtag ajsm tag Purpose F ind a Sem aphore Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup AMXID semid; char tag[4]; int status; . . status = ajsmtag(&semid, tag); AX BX= [DX:CX] see note Where semid is a pointer to storage for the semaphore id of the semaphore o f interest.
310 K A DAK AMX 86 Procedures ajsm wat ajsmwat Purpose Wait on a Semaphore Used by n Task o ISP o Time r Proce dure o Rest art Proced ure n Exit Proce dure Setup AMXID semid; long timeout; unsigned int priority; int status; .
AMX 86 Procedures K A DAK 311 ajsofs ajs ofs Purpose Set Poin ter Off set Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup unsigned int ofs; char FAR *pntr; . . ajsofs(&pntr, ofs); Results Interrupts are untouched.
312 K A DAK AMX 86 Procedures ajsseg ajs seg Purpose Set Poin ter Segmen t Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup unsigned short int seg; char FAR *pntr; . . ajsseg(&pntr, seg); Results Interrupts are untouched.
AMX 86 Procedures K A DAK 313 ajssr eg ajssr eg Purpose Set S egment Registers Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.
314 K A DAK AMX 86 Procedures ajsusp ajs usp Purpose Suspen d a Task Used by n Task o ISP n Time r Proce dure n Restart P roce dure n Exit Proced ure Setup AMXID taskid; int status; . . status = ajsusp(taskid); AX DX Where taskid is the task id of the task to be suspended.
AMX 86 Procedures K A DAK 315 ajtdf ajtdf Purpose Format Time and Date as an ASCII String Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup #include "amx831sd.h" . . struct amxtds tdbuf; char ascii[26]; int format; int n; .
316 K A DAK AMX 86 Procedures ajtdg ajtdg Purpose Get Cu rrent Time an d Date Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.h" . . struct amxtds tdbuf; . . ajtdg(&tdbuf); ES:BX Where &tdbuf is a pointer to the structure which is to receiv e the current time and date.
AMX 86 Procedures K A DAK 317 ajtds ajtds Purpose Set th e Time and Date Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup #include "amx831sd.h" . . struct amxtds tdbuf; . . Initialize tdbuf with new time and date.
318 K A DAK AMX 86 Procedures ajtick ajtick Purpose Read S ystem Tick Counter Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup unsigned long tickcnt; . . tickcnt = ajtick(); DX:AX Results Interrupts are untouched.
AMX 86 Procedures K A DAK 319 ajtk cre ajtk cre Purpose Create a New Task Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup #include "amx831sd.
320 K A DAK AMX 86 Procedures ajtk del ajtkdel Purpose Delete a Ta sk This procedure r emoves a task fr om your AMX s ystem. Its task id will no longer be valid. Used by n Task o ISP o Time r Proce dure o Rest art Proced ure n Exit Proce dure Setup AMXID taskid; int priority; int status; .
AMX 86 Procedures K A DAK 321 ajtk id ajtk id Purpose Get Task Id of Current Task Used by n Task o ISP o Time r Proce dure o Rest art Proced ure n Exit Proce dure Setup AMXID taskid; . . taskid = ajtkid(); AX Where taskid is the task id of the cur rently executing ta sk.
322 K A DAK AMX 86 Procedures ajtk ill ajtk ill Purpose Kill a Task This procedure will force a ready, executin g or suspended task to end. All messages in the ta sk's mailboxes at the time of the kill request will be flushed. All requests f or task execution pending at the time of the kill request will be e rased.
AMX 86 Procedures K A DAK 323 ajtk pry ajtkpry Purpose Chan ge Task Priority Used by n Task o ISP n Time r Proce dure n Restart P roce dure n Exit Proced ure Setup AMXID taskid; int priority; int status; . . status = ajtkpry(taskid, priority); AX DX CX Where taskid is the task id of the task whose priorit y is to be changed.
324 K A DAK AMX 86 Procedures ajtk stp ajtkstp Purpose Stop Execution of Task This procedure will f orce a ready, e xecuting or suspended task to end. Used by n Task n ISP n Time r Proce dure o Re start Pro ced ure n Exit Proce dure Setup AMXID taskid; int status; .
AMX 86 Procedures K A DAK 325 ajtk sts ajtksts Purpose Get Status of a Task Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.h" . . struct amxsbs tasksts; AMXID taskid; int status; . .
326 K A DAK AMX 86 Procedures ajtk tag ajtktag Purpose Find a Task Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup char tag[4]; AMXID taskid; int status; . . status = ajtktag(&taskid, tag); AX DX= [CX:DX] see note Where &taskid is a pointer to storage for the task id of the task o f interest.
AMX 86 Procedures K A DAK 327 ajtk tcb ajtktcb Purpose Get Task Control Block Pointer Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.h" . . struct amxtcbs *tcbp; AMXID taskid; int status; .
328 K A DAK AMX 86 Procedures ajtk trm ajtktrm Purpose En able/Disable Extern al Task Termination Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup AMXID taskid; void ttproc(); int status; .
AMX 86 Procedures K A DAK 329 ajtmcnv ajtm cnv Purpose Conver t Millisec onds to System Ticks Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup unsigned long ms; long ntick; . . ntick = ajtmcnv(ms); DX:CX DX:CX Where ms is the number of milliseconds.
330 K A DAK AMX 86 Procedures ajtmcr e ajtmcre Purpose Create an Interval Timer Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup void tproc(); AMXID timerid; long tperiod; struct tuser *tparam; char tag[4]; int status; .
AMX 86 Procedures K A DAK 331 ajtmdel ajtm del Purpose Delete an Interval Timer Used by n Task o ISP n Time r Proce dure n Restart P roce dure n Exit Proced ure Setup AMXID timerid; . . status = ajtmdel(timerid); AX DX Where timerid is the timer id identify in g the timer to be de leted.
332 K A DAK AMX 86 Procedures ajtmrd ajtm rd Purpose Read th e Current Value of an Interval Timer Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup AMXID timerid; long tval; . . tval = ajtmrd(timerid); DX:CX DX Where timerid is the timer id identify in g the timer whose value is r equired.
AMX 86 Procedures K A DAK 333 ajtmtag ajtm tag Purpose Find an Interval Tim e r Used by n Task o ISP o Time r Proce dure n Restar t Pro ced ure n Exit Procedure Setup AMXID timerid; char tag[4]; int status; .
334 K A DAK AMX 86 Procedures ajtm wr ajtmwr Purpose Start/Stop an Interval Timer Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup AMXID timerid; long tval; int status; . . status = ajtmwr(timerid, tval); AX DX BX:CX Where timerid is the timer id identifying the timer to be started or stopped.
AMX 86 Procedures K A DAK 335 ajtrig ajtr ig Purpose Trigger a T ask To request AMX to start a task without sending a message to the task. Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup AMXID taskid; int status; .
336 K A DAK AMX 86 Procedures ajtslv ajt slv Purpose Change a Task's Tim e Slice Interval Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup AMXID taskid; unsigned int tslice; int status; .
AMX 86 Procedures K A DAK 337 ajtsof ajt sof ajtson ajt son Purpose Disable Tim e Slicing Enable Tim e Slicing Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup ajtsof(); /* Disable time slicing */ or ajtson(); /* Enable time slicing */ Results Interrupts are untouched.
338 K A DAK AMX 86 Procedures ajupt ajupt Purpose Fetch Poin ter to User Para meter Tab le Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup #include "amx831sd.h" . . struct amxupts FAR *uptp; /* User Parameter Table pointer */ .
AMX 86 Procedures K A DAK 339 ajver ajver Purpose Get AMX Version Number Used by n Task n ISP n Time r Proce dure n Re start Proce dure n Exit Proced ure Setup unsigned long version; .
340 K A DAK AMX 86 Procedures ajwa it ajwa it Purpose Wait Unconditionally for a Wake Request Used by n Task o ISP o Time r Proce dure o Rest art Proced ure n Exit Proce dure Setup ajwait(); Results Interrupts are en abled. The task will be suspende d until some other task, I SP or Timer Procedure issues an ajwake call to wake this task.
AMX 86 Procedures K A DAK 341 ajwak c ajwak c Purpose Wake Calling Task (Acknowledge Receipt of Message) To allow the current ta sk to wake up the task which sent the messag e which is being processed b y the current task. Used by n Task o ISP o Time r Proce dure o Rest art Proced ure n Exit Proce dure Setup int status; .
342 K A DAK AMX 86 Procedures ajwak cs ajwak cs Purpose Wake Calling Task (Acknowledge Receipt of Message wi th Status) To allow the current ta sk to wake up the task which sent the messag e which is being proce ssed b y the current task and return completion status to that task.
AMX 86 Procedures K A DAK 343 ajwak e ajwak e Purpose Wake a Waiting Task To wake up a task known to be waiting because of an ajwait or ajwatm call. Used by n Task n ISP n Time r Proce dure o Re start Pro ced ure n Exit Proce dure Setup AMXID taskid; int status; .
344 K A DAK AMX 86 Procedures ajwap r ajwapr Purpose Reset a Pending Wake Request This call only affects the ca lling task. Used by n Task o ISP o Time r Proce dure o Rest art Proced ure n Exit Proce dure Setup ajwapr(); Results Interrupts are untouched.
AMX 86 Procedures K A DAK 345 ajwatm aj watm Purpose Task Delay or Timed Wait for a Wake Request Used by n Task o ISP o Time r Proce dure o Rest art Proced ure n Exit Proce dure Setup long tval; int status; . . status = ajwatm(tval); AX DX:CX Where tval is the required wait interval or del ay period measured in AMX system ticks.
346 K A DAK AMX 86 Procedures This page left blank intentionall y ..
AMX 86 Reserved Words K A DAK 347 A. AMX 86 Reserved W ords ajpppppp AMX C procedure name pppppp AAPPPPPP AMX assembl y lan guage procedure name PPPPPP amxttttt AMX C structure name of t ype ttttt AMX.
348 K A DAK AMX 86 Reserved Words This page left blank intentionall y ..
AMX 86 Error Co des K A DAK 349 B. AMX 86 Err o r Codes AMX error codes are signed inte gers. Codes less than zero are er ror codes. Codes greater than zero are warning codes. To assist y ou during testing , the hexadecimal va lue of the least significant 16-bits of the er ror code is listed as it might a ppear in a register or memory dump.
350 K A DAK AMX 86 Error Co des AMX 86 Er ror Codes ( continued) Mnem onic Value Value Meaning (dec) (hex) AERNBF -30 0xFFE2 No buffers defined AERNFP -31 0xFFE1 No free buffer pool AERNEB -32 0xFFE0 .
AMX 86 Error Co des K A DAK 351 AMX 86 Fatal Exit Codes Mnem onic Value Value Meaning (dec) (hex) AERFX1 ● 1 0x0001 Not enough memory in AMX Data Segment AERFX2 ● 2 0x0002 Divide, overflow, bound .
352 K A DAK AMX 86 Error Co des This page left blank intentionall y ..
Generator Specifications K A DAK 353 C. Configuration Gener a t or Specification s C.1 Intr oduction If you are not doing your software development on a PC or compatible runnin g Microsoft ® Windows ® , then y ou will be unable to use the interac tive Configuration Manager for Windows to create and edit y our AMX S y stem Configuration Module.
354 K A DAK Generator Specifications C.2 User Parameter File Specificatio n The User Para meter F ile is a tex t file str uctured a s illustrated in F igure C.2-1. The file consists of a sequence of k eywords of the form ...XXX which begin in column one.
Generator Specifications K A DAK 355 The example in Figure C.2-1 uses s y mbolic names for all of the parameters following each of the ke y wo rds. The symbols correspond to the screen fi elds described in Chapt er 14. You are referr ed to that chapter for detailed descriptions of ea ch of the parameters.
356 K A DAK Generator Specifications Each of your pred efined tasks must be defined using ke y word ...TDT . Th e order of these de finitions will determine their order of creation by AMX. If you do not wish to predefine any ta sks, delete the line with keyw ord .
Generator Specifications K A DAK 357 Each of your pred efined semaphore s must be defined using the ke y word ...SEM . The order of these def initions will determine their order of creation by AMX. If you do not wish to predefine an y semaphores, delet e the line with keyword .
358 K A DAK Generator Specifications Each of your pred efined message exchanges must be defined using the keyword ...MEX . The order of these definitions will determine the ir order of creation by AMX. I f y ou do not wish to predefine any message ex changes, delete the line with keyword .
Generator Specifications K A DAK 359 C.3 System Configurat ion T emplate The Sy stem Configur ation Template is an a ssembly language source file which defines a System Config uration Module for any system using AMX and its managers. It is recomme nded that you list file AM831CG.
360 K A DAK Generator Specifications Macro para meters appea r in the macro body as parameter ide ntifiers. A par ameter identifier is a decimal integer preced ed and followe d b y the delimiter character d efined in the macro definiti on statement ( ~1~ , ~2~ , etc.
Generator Specifications K A DAK 361 The first statem ent in this ex ample is a directi ve defining an in cremental variabl e named &TN . Both its initial value and increme nt are 1.
362 K A DAK Generator Specifications C.4 Porting the C onfigurat ion Gener a tor The Configuration Manager uses the Configuration Generator to ge nerate your System Configuration Module. If you are not doing your development on a PC or compatible, you may wish to port the Configuration Generator to y our d evelopment system.
Generator Specifications K A DAK 363 By defa ult, the Configura tion Generator uses the ma cro identific ation characte r ( ; in our exampl e) from the macro directive as a com ment charact er to identif y the com ments inserted into the output file in response to the -w switch.
364 K A DAK Generator Specifications This page left blank intentionall y ..
Structure/Consta nt Def initions K A DAK 365 D. AMX 86 S tructure and Constant Defi nitions D.1 AMX C S tructures and Consta nts AMX Laun ch Parameter (s ee AAENTR ) #define AMLPTMP 1 /* Temporary lau.
366 K A DAK Structure/Consta nt Def initions AMX Task Stat us Block Struc ture struct amxsbs { AMXID amsbtid; /* task id */ char amsbtag1; /* task tag */ char amsbtag2; char amsbtag3; char amsbtag4; u.
Structure/Consta nt Def initions K A DAK 367 AMX Extend ed Message Paramete r Structur e (passed on stack above AM X message when starting a task) struct amxmsgxs { AMXID amxmscid; /* calling task&apo.
368 K A DAK Structure/Consta nt Def initions AMX User Para meter Tabl e Structur e struct amxupts { void (**ampbrpl)(); /* A(Restart Procedure List) */ void (**ampbepl)(); /* A(Exit Procedure List) */.
Structure/Consta nt Def initions K A DAK 369 Configuration A ttribut es (field AMPBCFGA ) #define AMCAMTK 1 /* Some Medium tasks */ #define AMCAMUP 2 /* Some Medium user procedures */ #define AMCAS24 .
370 K A DAK Structure/Consta nt Def initions AMX List He ader St ructure (doubly linked list s) struct amxlhs { struct amxlhs *amlhhead; /* list head */ struct amxlhs *amlhtail; /* list tail */ unsign.
Structure/Consta nt Def initions K A DAK 371 AMX Register A rray Structure struct amxregs { unsigned short int amxrf; /* Flags (LS byte only) */ unsigned short int amxrax; /* Register AX */ unsigned s.
372 K A DAK Structure/Consta nt Def initions AMX C Jump Bu ffer Stru cture struct ajxjbuf { unsigned short int xjbretadr; /* ofs(return address) */ unsigned short int xjbcs; /* Register CS */ unsigned.
Structure/Consta nt Def initions K A DAK 373 D.2 AMX Assembler S tructur es and Constants AMX Laun ch Parameter (s ee AAENTR ) AMLPTMP EQU 1 ;Temporary launch ; ;Default is permanent launch ; AMLPVA E.
374 K A DAK Structure/Consta nt Def initions AMX Task Stat us Block Struc ture AMXSBS STRUC ; AMSBTID DW ? ;task id AMSBTAG1 DB ? ;task tag AMSBTAG2 DB ? AMSBTAG3 DB ? AMSBTAG4 DB ? AMSBST DD ? ;task .
Structure/Consta nt Def initions K A DAK 375 AMX Extended Message Paramete r Structure (passed on stack above AM X message when starting a task) AMXMSGXS STRUC ; AMXMSCID DW ? ;calling task's id .
376 K A DAK Structure/Consta nt Def initions AMX User Para meter Tabl e Structur e AMXUPTS STRUC ; AMPBRPL DD ? ;A(Restart Procedure List) AMPBEPL DD ? ;A(Exit Procedure List) AMPBCFGA DD ? ;Configura.
Structure/Consta nt Def initions K A DAK 377 Configuration A ttribut es (field AMBPCFGA ) AMCAMTK EQU 1 ;Some Medium tasks AMCAMUP EQU 2 ;Some Medium user procedures AMCAS24 EQU 4 ;Use 24-bit address .
378 K A DAK Structure/Consta nt Def initions AMX List He ader St ructure (doubly linked list s) AMXLHS STRUC ; AMLHHEAD DD ? ;Head of list AMLHTAIL DD ? ;Tail of list AMLHOFFS DW ? ;Byte offset to obj.
Structure/Consta nt Def initions K A DAK 379 AMX Register A rray Structure AMXREGS STRUC ; AMXRF DW ? ;Flags (LS byte only) AMXRAX DW ? ;Register AX AMXRBX DW ? ;Register BX AMXRCX DW ? ;Register CX A.
380 K A DAK Structure/Consta nt Def initions This page left blank intentionall y ..
AMX 86 Assembler Interface K A DAK 381 E. AMX 86 Assembler Interface This appendix summarizes the a ssembly language ca lling sequences for a ll AMX procedures. The procedur es are organized in functional groups. Within each group the procedures are listed alphabetic ally.
382 K A DAK AMX 86 Assembler Interface The following notes are refer enced in the procedure descriptions in this appendix . Note: 1. All registers are pres erved, including AX . 2. Registers CX , DX , SI are unalt ered. All other registers a re undefined.
AMX 86 Assembler Interface K A DAK 383 PROCEDURE C ASM PURP OSE PARAME TERS IN OUT AX = ERRORS E D R System Control ajentr AA ENTR E nter A MX multit asking w orld L aunch Parame ters BX no nnn Exit a.
384 K A DAK AMX 86 Assembler Interface PROCEDURE C ASM PURP OSE PARAME TERS IN OUT AX = ERRORS E D R Task Control aj end AA END End ta sk execu tion no no o (no retu rn ) ajgmsg AAGMSG Get message fro.
AMX 86 Assembler Interface K A DAK 385 PROCEDURE C ASM PURP OSE PARAME TERS IN OUT AX = ERRORS E D R Task Control (continue d) ajtki ll AATKIL L Kill a task Task id DX AERNST on n AER AN A ajtkpry AAT.
386 K A DAK AMX 86 Assembler Interface PROCEDURE C ASM PURP OSE PARAME TERS IN OUT AX = ERRORS E D R Interrupt Co ntrol ajint AAI NT Begin inte rrupt ser vice AMX I nterr upt St ack S S:S P Note 2 ono.
AMX 86 Assembler Interface K A DAK 387 PROCEDURE C ASM PURP OSE PARAME TERS IN OUT AX = ERRORS E D R Timing Co ntrol ajclk AACLK A MX Clo ck Handle r Note 1 nnn ajti ck A A T ICK Read elaps ed s ystem.
388 K A DAK AMX 86 Assembler Interface PROCEDURE C ASM PURP OSE PARAME TERS IN OUT AX = ERRORS E D R Semaphore Manag er ajsmcre AAS MCRE Cre ate a se maphore I nitial value (0 to 327 67) BX A ERISV on.
AMX 86 Assembler Interface K A DAK 389 PROCEDURE C ASM PURP OSE PARAME TERS IN OUT AX = ERRORS E D R Event M ana ger ajevc re AAEVCRE Create a n event grou p Init ial va lu e for event group B X AERNE.
390 K A DAK AMX 86 Assembler Interface PROCEDURE C ASM PURP OSE PARAME TERS IN OUT AX = ERRORS E D R Messa ge Ex chan ge Manager ajmxcre AA MXCRE Create a m essage ex change Tag DX :CX AERNXB on n A( .
AMX 86 Assembler Interface K A DAK 391 PROCEDURE C ASM PURP OSE PARAME TERS IN OUT AX = ERRORS E D R Buffer M anager ajba u AA BAU Add to buffer use count A( buffe r) ES :BX AER BNU on n Increm en t f.
392 K A DAK AMX 86 Assembler Interface PROCEDURE C ASM PURP OSE PARAME TERS IN OUT AX = ERRORS E D R Memory Manager ajm au A AM AU Add to block use count A(memor y block) ES:BX AER MIB on n Increm en .
AMX 86 Assembler Interface K A DAK 393 PROCEDURE C ASM PURP OSE PARAME TERS IN OUT AX = ERRORS E D R Link ed List Mana ger ajlcre AAL CRE Create an e mpty list A(List He ader) DS:SI no ooo Node offset.
394 K A DAK AMX 86 Assembler Interface PROCEDURE C ASM PURP OSE PARAME TERS IN OUT AX = ERRORS E D R Link ed List Mana ger (continue d) ajlrm vc AALRMVC R emove speci fic obj ec t from list A(List Hea.
Index K A DAK Index- 1 Numerals 24-bit m emory addre ssing 1, 12 5, 171 A AACLK 73 AAENTR 22 AAI NT 54, 55, 56, 7 3 AA INX 55, 56 , 73 ajabl 13 5, 205 ajatl 13 5, 206 ajbau 52, 119, 1 21, 207 ajbcr e .
Index- 2 K A DAK Index ajsm cre 91, 93, 94 , 95, 98, 99, 174, 183, 301 ajsm del 91, 93, 99, 30 2 ajsmf re 91, 95, 303 ajsmget 9 1 , 94, 304 ajsm rls 91, 95, 305 ajsmrs v 28, 91, 95, 96, 306 ajsms ig 5.
Index K A DAK Index- 3 Class of AMX service buff er pool, buff er 197 C langua ge inte rfa ce 199 circular list 198 counting semaphor e 196 eve nt group 196 interrupt co ntrol 19 4 linked list 198 mem.
Index- 4 K A DAK Index F FAR pointe rs 204 Fatal error 3 Fatal exit 3, 60, 147, 14 8, 149, 175 Fatal ex it codes 147, 1 48, 149, 351 Fatal Exit Procedure 147 , 148 , 149 , 175 interrupt state 148 stac.
Index K A DAK Index- 5 M Mailbox 4, 26 (see Message (task), mailbox) ack nowle dge me ssage 35 mess age que ue 4 Make utilitie s (Refer to AMX Tool Guid es) malloc 12 5 Math coproc e s s or 101, 10 2,.
Index- 6 K A DAK Index P PC Super visor (see PC Superv isor Ref erence Ma nual) Service P rocedure Su mmary 200 Preem ption 13 Priority (see Ev ent group, w ait for event(s )) (see Kernel Task, p rior.
Index K A DAK Index- 7 Stack s ize Exit Procedure s 44, 45 Fatal Exit Procedure 1 48 Interrupt Service Procedu re 51, 56, 65 Interrupt Stac k 51, 56, 6 5, 171 Kernel Sta ck 42, 43, 65, 76, 77, 85, 8 6.
Index- 8 K A DAK Index Task term ination 153, 15 4, 155, 156, 157 delete 154, 155, 15 6, 15 7 deletion pri ority 157 enable/disable 154 kill 154, 155, 156, 15 7 Service P rocedure Su mmary 195 stop 15.
デバイスAMX 86の購入後に(又は購入する前であっても)重要なポイントは、説明書をよく読むことです。その単純な理由はいくつかあります:
AMX 86をまだ購入していないなら、この製品の基本情報を理解する良い機会です。まずは上にある説明書の最初のページをご覧ください。そこにはAMX 86の技術情報の概要が記載されているはずです。デバイスがあなたのニーズを満たすかどうかは、ここで確認しましょう。AMX 86の取扱説明書の次のページをよく読むことにより、製品の全機能やその取り扱いに関する情報を知ることができます。AMX 86で得られた情報は、きっとあなたの購入の決断を手助けしてくれることでしょう。
AMX 86を既にお持ちだが、まだ読んでいない場合は、上記の理由によりそれを行うべきです。そうすることにより機能を適切に使用しているか、又はAMX 86の不適切な取り扱いによりその寿命を短くする危険を犯していないかどうかを知ることができます。
ですが、ユーザガイドが果たす重要な役割の一つは、AMX 86に関する問題の解決を支援することです。そこにはほとんどの場合、トラブルシューティング、すなわちAMX 86デバイスで最もよく起こりうる故障・不良とそれらの対処法についてのアドバイスを見つけることができるはずです。たとえ問題を解決できなかった場合でも、説明書にはカスタマー・サービスセンター又は最寄りのサービスセンターへの問い合わせ先等、次の対処法についての指示があるはずです。