Changes for page API контроллеров AZ®
Last modified by Max on 2025/03/02 15:18
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -15,7 +15,6 @@ 15 15 * 177224 - Primary Boot Register (BOOT1) 16 16 * 177226 - Alternate Boot Register (BOOT2) 17 17 18 - 19 19 The CSR register accepts commands in bits D0-D5 and the interrupt enable bit in bit D6, all write only, always zero is read. In bit D7, the readiness bit is read. One in it means that the previous command has been executed and the controller is ready for exchange. Zero means that the controller is busy executing the previous operation, the other registers are disabled, access to any of them will cause Trap to 4. If the execution of the previous command caused an error, bit D15 is set simultaneously with bit D7. 20 20 \\Writing to registers is done only in words; byte writing is not allowed. 21 21 \\All data exchange is conducted via DR. For commands with a single-word argument, this argument should be sent to DR, and then the command should be sent to CSR. For commands exchanging with the controller buffer, on the contrary, the command should be issued and only after it a data block of a certain length should be received or transmitted. ... ... @@ -249,51 +249,51 @@ 249 249 == 005: Reading block into buffer == 250 250 251 251 The controller has a built-in buffer for 256 words (512 bytes). In fact, this is part of the STM32 microcontroller's RAM, allocated in its program for this buffer. All exchange in the main command block goes through this buffer. 252 -\\ ПамятьдисковAZпредставлена,какнаборблоковобъемом512байткаждый.Такойблок-единственнаядоступнаяединицадляобменаданнымисдискамиAZ.Блокипронумерованыотнулядо65533для16-разрядноговариантаилидо8388607для32-разрядного-этоприиспользованиинакопителейAZмаксимальнодопустимойемкости.Никтонемешаетиспользоватьнакопителименьшейемкости-фактическийразмернакопителяравенразмеруфайл-образа,смонтированногонаэтотнакопитель.Припопыткеобратитьсязапределыфайл-образабудетзарегистрированаошибка.253 -\\ Команда005 -чтениеблокасMicroSDв [[буфер>>doc:||anchor="Micro"]].СпсевдодискаAZn,выбранногоранеекомандой"Выборустройства"запускаетсяначтениеблок,номеркоторогопереданкомандой(командами) "Установканомераблока".Командадлительногодействия.254 -\\ Фактически,блокскарточкиMicroSDчитается,примерно,500-800мкс.Наэтовремяконтроллерпереходитвсостояние,котороевовремяобсужденияпроектаполучилоназвание"Думаю,прошунемешать."А именно,навсевремяееисполненияотключаютсявсерегистрыустройства,кромеCSR,вкоторомсчитываетсянольдотехпор,покаконтроллерзанятисполнениемэтойкоманды.ПоокончаниисчитыванияблокакМПИподключаютсяостальныерегистрыконтроллера,взводитсябитD7 (готовность)вCSRи,еслибылустановлен битD6 (разрешениепрерываний)вCSR,вырабатываетсяпрерываниесвектором0174.255 -\\ Примербезпрерыванийтривиален:251 +\\The AZ disk memory is represented as a set of blocks, each 512 bytes in size. Such a block is the only available unit for exchanging data with AZ disks. The blocks are numbered from zero to 65533 for the 16-bit version or up to 8388607 for the 32-bit version - this is when using AZ drives of the maximum permissible capacity. No one prevents you from using drives of a smaller capacity - the actual size of the drive is equal to the size of the file-image mounted on this drive. An error will be registered if you try to access beyond the file-image. 252 +\\Command 005 - reading a block from MicroSD to the buffer. From the pseudo-disk AZn, previously selected by the command "Select device", the block whose number is transmitted by the command (commands) "Set block number" is started for reading. Long-term command. 253 +\\In fact, a block from a MicroSD card is read in about 500-800 µs. During this time, the controller goes into a state that during the discussion of the project was called "I think, please do not interfere." Namely, for the entire time of its execution, all device registers are disabled, except for CSR, in which zero is read as long as the controller is busy executing this command. After the block is read, the remaining controller registers are connected to the QBUS, bit D7 (ready) is set in CSR and, if bit D6 (interrupt enable) was set in CSR, an interrupt with vector 0174 is generated. 254 +\\An example without interruptions is trivial: 256 256 257 257 {{code language="assembler"}} 258 258 ;................................... 259 259 260 -CmdRea=005; символическое наименование команды "Читать 261 -; блок" 259 +CmdRea=005; symbolic name of the "Read block" command 262 262 263 -; ВR3унасотпредыдущегофрагментаосталсяадресCSR.264 -; Пересылаемтудакодкомандычтения261 +; In R3 we have the CSR address left from the previous fragment. 262 +; We send the read command code there 265 265 MOV #CmdRea,@R3 266 -2$: TSTB @R3 ;Проверимбитготовности267 - BPL 2$; Неготово->уходимпроверятьеще268 - раз269 - TST @R3; Проверимнаошибку264 +2$: TSTB @R3 Let's check the ready bit 265 + BPL 2$; Not ready -> we go to check again 266 +; once 267 + TST @R3; Let's check for an error 270 270 BMI ERR4 271 -; Здесьу нас опять,вотличиеотфрагментовпп. 3.1и272 -; 3.2, вR3осталсяадресCSR,анеDR.269 +; Here again, unlike the fragments of pp. 3.1 and 270 +; 3.2, we have the CSR address left in R3, not DR. 273 273 274 274 ;................................... 275 275 {{/code}} 276 276 277 277 278 -== **006:Записатьблокизбуферанадиск**==276 +== 006: Write block from buffer to disk == 279 279 280 -Код команды 006. Содержимое буфера пишется на выбранный псевдодиск по заданному дисковомк адресу (номеру блока). Перед записью выполняются проверки (1) "была ли запись в буфер?", если нет, выдается ошибка и (2) "заполнен ли буфер полностью?", если нет (для последнего укороченного блока файла), остаток буфера очищается нулями. Далее производится запись блока на носитель. Операция длительная, после ее запуска контроллер, как и при чтении переходит в состояние "Думаю, прошу не мешать". И так же, как и при чтении окончания этой операции надо дождаться, теми же средствами, как и при чтении. 281 -\\Пример программы без прерываний: 278 +Command code 006. The buffer contents are written to the selected pseudo-disk at the specified disk address (block number). Before writing, checks are performed (1) "was there a write to the buffer?", if not, an error is returned and (2) "is the buffer completely filled?", if not (for the last shortened block of the file), the rest of the buffer is cleared with zeros. Then the block is written to the media. The operation is lengthy, after it is started the controller, as with reading, goes into the "I think, please do not interfere" state. And just as with reading, you must wait for the end of this operation, by the same means as with reading. 282 282 280 + 281 +Example of a program without interrupts: 282 + 283 283 {{code language="assembler"}} 284 284 ;............................................................... 285 285 286 -CmdWri=006; символическоенаименованиекоманды"Писать287 - блок"286 +CmdWri=006; symbolic name of the "Write 287 +; block" command 288 288 289 -; ВR3унасотпредыдущегофрагментаосталсяадресDR.290 -; ИсправляемегонаCSRипересылаемтуда код команды291 -; записи289 +; In R3 we have the DR address left over from the previous fragment. 290 +; We correct it to the CSR and send the 291 +; write command code there 292 292 MOV #CmdWri,-(R3) 293 -5$: TSTB @R3 ; Проверим бит готовности 294 - BPL 5$; Не готово -> уходим проверять еще 295 - ; раз 296 - TST @R3; Проверим на ошибку 293 +5$: TSTB @R3 ; Let's check the ready bit 294 + BPL 5$; Not ready -> we go and check again once 295 + TST @R3; Let's check for an error 297 297 BMI ERR5 298 298 299 299 ;.................................................................... ... ... @@ -300,73 +300,73 @@ 300 300 {{/code}} 301 301 302 302 303 -== **007:Получитьразмерпсевдодиска**==302 +== 007: Get disk size == 304 304 305 - Естьдвекомандыполученияразмерапсевдодиска,т.е.смонтированногонавыбранныйпсевдоприводAZnфайл-образа.306 -\\ ЕслииспользуемаяОС(илипрограмма,работающаясдискамибезОС)умеетработатьсбольшими(больше32М)дисками,следуетпользоваться[[командойскодом 017>>doc:||anchor="H017:A041F43E43B44344743844244C44043043743C43544043F44143543243443E43443844143A4302C43143E43B44C44843E439"]].Последовательностьдействий:сброситьконтроллер(команда000),выбратьнакопитель(п. 3.2)ипереслатьвCSRкод017,азатем,безкаких-либоожиданий,считатьизDRсначаламладшее,иследомзанимстаршеесловоразмеравыбранногонакопителя(файл-образа).307 -\\ ЕслииспользуемаяОСнеумеетработатьсдискамибОльшими,чем32М(RT-11),следуетпользоватьсякомандой007 -получитьразмерпсевдодискасограничениемдо32М.Действияпохожие:сбрасываемконтроллер,выбираемдиск,посылаемвCSRкод007исчитываемизDRоднословоразмерапсевдодиска.Еслиразмерфайл-образа,смонтированногонавыбранныйпсевдопривод,больше65534блоков,вместоэтого"большого"размера,контроллервозвращает число65534.Напоминаем,чточисло65535кое-гдеиспользуетсявспециальныхцеляхинеможетбытьразмеромдиска.308 -\\ Такженапоминаем,чтоеслинаэтотнакопительнесмонтированфайл-образ,последовательностьдействийнепройдет(команда001выборустройства)иисполнениепрограммыдоэтогоместапростонедойдет.Поэтомуошибокуэтихкоманднепредусмотрено.304 +There are two commands for obtaining the size of a pseudo-disk, i.e. the AZn file-image mounted on the selected pseudo-drive. 305 +\\If the OS being used (or a program working with disks without an OS) can work with large (more than 32M) disks, you should use the command with the code 017. The sequence of actions: reset the controller (command 000), select the drive (p. 3.2) and send the code 017 to the CSR, and then, without any waiting, read from DR first the lower word, and then the higher word of the size of the selected drive (image file). 306 +\\If the OS you are using cannot work with disks larger than 32M (RT-11), you should use the 007 command - get the pseudo-disk size with a limit of up to 32M. The steps are similar: reset the controller, select the disk, send the 007 code to the CSR and read one word of the pseudo-disk size from DR. If the size of the image file mounted on the selected pseudo-drive is larger than 65534 blocks, the controller returns the number 65534 instead of this "large" size. We remind you that the number 65535 is used in some places for special purposes and cannot be the disk size. 307 +\\We also remind you that if the image file is not mounted on this drive, the sequence of actions will not work (command 001 select device) and the program execution will simply not reach this point. Therefore, these commands do not provide for errors. 309 309 310 - Примерпрограммыс"малыми"дисками309 +Example of a program with "small" disks 311 311 312 312 {{code language="assembler"}} 313 313 ;...................................... 314 314 315 -GetSiz=007; Получить"малый"размердиска314 +GetSiz=007; Get the "small" disk size 316 316 317 -; Отфрагмента3.2 (выбордиска)унасвR3остался318 -; адресDR (177222)316 +; From fragment 3.2 (disk selection) we have in R3 317 +; DR address (177222) 319 319 320 - MOV #GetSiz,-(R3); пошлемкоманду321 - TST (R3)+; вернемадресвR3назад,наDR319 + MOV #GetSiz,-(R3); send the command 320 + TST (R3)+; return the address in R3 back to DR 322 322 MOV @R3,DskSiz 323 323 ;...................................... 324 324 {{/code}} 325 325 326 -== **010:Разрешитьработусети**==325 +== 010: Allow network operation == 327 327 328 -Код команды 010. Закончив последовательность действий по передаче очередной порции данных, и ожидая, что следующий запрос последует не сразу же, можно "утилизировать" процессорное время микроконтроллера STM32, составляющего основу AZ - занять его обслуживанием сети. В той же RT-11 это можно сделать перед выходом из драйвера AZ, перед макрокомандой .DRFIN, завершающей исполнение запроса ввода-вывода. 329 -\\Действительно, операция ввода-вывода завершена, программа ЦП в системе будет готовить новую порцию данных для вывода, или соображать (на основании предыдущих прочитанных данных), где ей еще что-то прочитать, или вообще размышлять о чем-то своём. [[image:https://forum.maxiol.com/style_emoticons/default/smile.gif||alt="smile.gif"]] Другими словами, после окончания запроса ввода-вывода, довольно высока вероятность того, что последует пауза в работе с дисками AZ. Вот, время этой паузы и можно отдать на обслуживание сети. Для этого, перед исполнением макрокоманды .DRFIN в RT-11 или ее аналога в других ОС следует отправить в CSR код 110 (разрешить сеть плюс разрешить прерывания). 330 -\\Прерывание в этом случае не произойдет, оно активируется только по завершении "длительных" операций, которые переводят контроллер в состояние "Думаю, прошу не мешать", а установленный в "1" триггер разрешения прерываний, кроме этого, разрешает еще и работу сети, если она активирована. При запуске следующей операции ввода-вывода действия в п. 3.1 (сброс контроллера) сбросят и этот триггер, после чего программа обслуживания сети, обнаружив сброс этого триггера, прекратит (приостановит) свою работу и вернет управление основной программе обслуживания дисков AZ. Максимум, что можно заметить со стороны ЦП - это небольшая (10-20 мкс) задержка исполнения команды сброса, но это вполне умеренная плата за сетевые возможности. 331 - 327 +Command code 010. Having completed the sequence of actions for transferring the next portion of data, and expecting that the next request will not follow immediately, you can "utilize" the processor time of the STM32 microcontroller, which is the basis of AZ - occupy it with servicing the network. In the same RT-11, this can be done before exiting the AZ driver, before the .DRFIN macro command, which completes the execution of the input-output request. 328 +\\Indeed, the I/O operation is completed, the CPU program in the system will prepare a new portion of data for output, or figure out (based on the previously read data) where it should read something else, or generally think about something of its own. smile.gif In other words, after the I/O request is completed, there is a fairly high probability that there will be a pause in working with the AZ disks. So, the time of this pause can be given to servicing the network. To do this, before executing the .DRFIN macro in RT-11 or its analogue in other OS, you should send code 110 (enable network plus enable interrupts) to the CSR. 332 332 333 -== **011: Получить таблицу назначений приводов AZn** == 334 334 335 -Код команды 011. Получив эту команду, контроллер переключается с буфера для блока на свою внутреннюю таблицу назначений (32 строки по 140 байт каждая)* . Перед выдачей этой команды следует сбросить контроллер. После выдачи этой команды следует выдать команду 015 (чтение буфера), но в этом случае будет читаться не буфер, а та самая таблица, последовательно, слово за словом. 336 -\\* начиная с версии v17, длина имени файла уже не 130 байт, а 386 байт (последнее слово - нулевое, для окончания строки) 331 +In this case, the interrupt will not occur, it is activated only upon completion of "long" operations that transfer the controller to the "Thinking, please do not interfere" state, and the interrupt enable trigger set to "1" also enables network operation if it is activated. When the next input-output operation is started, the actions in paragraph 3.1 (controller reset) will also reset this trigger, after which the network service program, having detected the reset of this trigger, will stop (suspend) its work and return control to the main disk service program AZ. The maximum that can be noticed from the CPU side is a small (10-20 µs) delay in executing the reset command, but this is a very reasonable price for network capabilities. 337 337 338 - [[**//примерутилитыAZSMNT//**>>url:https://forum.maxiol.com/index.php?s=&showtopic=5605&view=findpost&p=59420]]333 +== 011: Get AZn drive assignment table == 339 339 335 +Command code 011. Upon receiving this command, the controller switches from the block buffer to its internal assignment table (32 lines of 140 bytes each)*. Before issuing this command, the controller should be reset. After issuing this command, command 015 (read buffer) should be issued, but in this case it will not be the buffer that is read, but the same table, sequentially, word by word. 336 +\\* starting with v17, the file name length is no longer 130 bytes, but 386 bytes (the last word is zero, to end the line) 340 340 341 - Примерпрограммы:338 +[[AZSMNT utility example>>url:https://forum.maxiol.com/index.php?s=&showtopic=5605&view=findpost&p=59420]] 342 342 340 + 341 +Example program: 342 + 343 343 {{code language="assembler"}} 344 344 ;................................... 345 -AZ$CSR = 177220; CSR контроллера346 -RdBuf = 012; Команда"Читатьизпамятиконтроллера"347 -RdTbl = 011; Команда"Читатьтаблицуназначений"348 -TblSiz = 1120.; Длинатаблицывбайтах(десятичная)345 +AZ$CSR = 177220; Controller CSR 346 +RdBuf = 012; Command "Read from controller memory" 347 +RdTbl = 011; Command "Read assignment table" 348 +TblSiz = 1120.; Table length in bytes (decimal) 349 349 350 -; Считаем, что в R2 находится адрес первого слова 351 -; области памяти для таблицы назначений. Процедуру 352 -; получения этого адреса не показываем. 350 +; We assume that R2 contains the address of the first word of the 351 +; memory area for the assignment table. We do not show the procedure for obtaining this address. 353 353 354 - MOV #AZ$CSR,R3; ГотовимCSRконтроллера353 + MOV #AZ$CSR,R3; Preparing the controller CSR 355 355 10$: CLR @R3; 356 - TSTB @R3; Сбросимконтроллер355 + TSTB @R3; Reset the controller 357 357 BPL 10$; 358 358 359 - MOV #RdTbl,@R3; Команда"Передать360 - ; таблицу"358 + MOV #RdTbl,@R3;Command "Transfer 359 + ; table" 361 361 362 - MOV #RdBuf,(R3+); Команда"Читатьиз363 -; памятиконтроллера.ОдновременнопередвинемадресвR3364 -; наDRконтроллера(177222).361 + MOV #RdBuf,(R3+); Command "Read from 362 +; controller memory. At the same time, move the address in R3 363 +; to the DR of the controller (177222). 365 365 366 - MOV #TblSiz/2,R1; Готовимсчетчикслов365 + MOV #TblSiz/2,R1; Prepare the word counter 367 367 368 -11$: MOV @R3,(R2)+; Перешлемтекущееслово369 - иповторим560раз367 +11$: MOV @R3,(R2)+; Send the current word 368 +SOB R1,11$; and repeat 560 times 370 370 ;................................... 371 371 {{/code}} 372 372