⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rom_offsets.inc

📁 tini的http-slientC程序
💻 INC
📖 第 1 页 / 共 2 页
字号:
; ---------------------------------------------------------------------------
;  Copyright (C) 2003-2004 Dallas Semiconductor Corporation, All Rights Reserved.
; 
;  Permission is hereby granted, free of charge, to any person obtaining a
;  copy of this software and associated documentation files (the "Software"),
;  to deal in the Software without restriction, including without limitation
;  the rights to use, copy, modify, merge, publish, distribute, sublicense,
;  and/or sell copies of the Software, and to permit persons to whom the
;  Software is furnished to do so, subject to the following conditions:
; 
;  The above copyright notice and this permission notice shall be included
;  in all copies or substantial portions of the Software.
; 
;  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
;  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;  MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
;  IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
;  OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
;  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
;  OTHER DEALINGS IN THE SOFTWARE.
; 
;  Except as contained in this notice, the name of Dallas Semiconductor
;  shall not be used except as stated in the Dallas Semiconductor
;  Branding Policy.
; ---------------------------------------------------------------------------
;
;  This file contains some equates for the 400 and some macros for calling
;  the built-in ROM functions.  There are also a couple utilities for 
;  putting characters out to the serial port.
;
;  Some of the ROM functions say they are "not defined for the C compiler".
;  This does not mean you can't call these functions, only that no wrapper
;  functions exist to call these from C.
;
;  In the Keil compiler, this file creates a 'warning A41: MISSING 'END' STATEMENT'
;  which can be ignored, as this file only contains macros and equates.
;
; ---------------------------------------------------------------------------
;

wos_crit_count_reg equ 68h
 
R0_B0     equ 0                         ; Register bank 0 equates.
R1_B0     equ 1
R2_B0     equ 2
R3_B0     equ 3
R4_B0     equ 4
R5_B0     equ 5
R6_B0     equ 6
R7_B0     equ 7
;
R0_B1     equ 8                         ; Register bank 1 equates.
R1_B1     equ 9
R2_B1     equ 0AH 
R3_B1     equ 0BH 
R4_B1     equ 0CH 
R5_B1     equ 0DH 
R6_B1     equ 0EH 
R7_B1     equ 0FH 
;
R0_B2     equ 10H                       ; Register bank 2 equates.
R1_B2     equ 11H 
R2_B2     equ 12H 
R3_B2     equ 13H
R4_B2     equ 14H
R5_B2     equ 15H
R6_B2     equ 16H
R7_B2     equ 17H
;
R0_B3     equ 18H                       ; Register bank 3 equates.
R1_B3     equ 19H
R2_B3     equ 1AH
R3_B3     equ 1BH
R4_B3     equ 1CH
R5_B3     equ 1DH
R6_B3     equ 1EH
R7_B3     equ 1FH

; assumed to never be 0 by rom400_lib_sock.a51
PARAM_BUFFER_SIZE     EQU  (255*3)
;
; Default save size that should be used for ROM processes.
; 104 Bytes of directs, sp, esp, stack.  Used for task creation functions.
;
ROM_SAVESIZE	      EQU 384 

;
; Overhead values for the TFTP code.  There are 4 bytes of TFTP config info, 
; and 3 bytes at the head of each array for Java native conventions.
;
ROM_TFTP_OVERHEAD     EQU 4
JAVA_ARRAY_HACK       EQU 3

;
; The size of a pointer
;
POINTER_SIZE          EQU 3

;
; The max number of sockets we will ever see.  Socket handles should
; be between 0 and this (number-1) inclusive.
;
MAX_SOCKETS           EQU 24

;
; The top of the redirect function table in RAM.
;
CALL_TABLE_TOP        EQU 256
;
; The bank the ROM is stored in.  Should be 0FFh for production
; 400's.  Change this value when running with a debug ROM.
;
ROM_BANK              EQU 0FFh
;
; The address of the ROM export table is stored 
; at (ROM_BANK << 16) | ROM_EXPORTTABLE_OFFS
;
ROM_EXPORTTABLE_OFFS  EQU 2

;
; Each entry in the ROM export table is 3 bytes.
;
ROMXT_ENTRYSIZE       EQU 3

;
; The number of functions in the ROM export table is stored
; first in the export table.
;
ROMXT_NUMFUNCTIONS             EQU   (0 * ROMXT_ENTRYSIZE)



;
; Each entry in the ROM Redirect table is 3 bytes.
;
ROMRT_ENTRYSIZE                      EQU  3

;
; ROM REDIRECT TABLE FUNCTIONS (denoted with ROMRT)
;
ROMRT_KERNELMALLOC                   EQU  1 * ROMRT_ENTRYSIZE
ROMRT_KERNELFREE                     EQU  2 * ROMRT_ENTRYSIZE
ROMRT_MALLOC                         EQU  3 * ROMRT_ENTRYSIZE
ROMRT_FREE                           EQU  4 * ROMRT_ENTRYSIZE
ROMRT_MALLOCDIRTY                    EQU  5 * ROMRT_ENTRYSIZE
ROMRT_DEREF                          EQU  6 * ROMRT_ENTRYSIZE
ROMRT_GETFREERAM                     EQU  7 * ROMRT_ENTRYSIZE
ROMRT_GETTIMEMILLIS                  EQU  8 * ROMRT_ENTRYSIZE
ROMRT_GETTHREADID                    EQU  9 * ROMRT_ENTRYSIZE
ROMRT_THREADRESUME                   EQU 10 * ROMRT_ENTRYSIZE
ROMRT_THREADIOSLEEP                  EQU 11 * ROMRT_ENTRYSIZE
ROMRT_THREADIOSLEEPNC                EQU 12 * ROMRT_ENTRYSIZE
ROMRT_THREADSAVE                     EQU 13 * ROMRT_ENTRYSIZE
ROMRT_THREADRESTORE                  EQU 14 * ROMRT_ENTRYSIZE
ROMRT_SLEEP                          EQU 15 * ROMRT_ENTRYSIZE
ROMRT_GETTASKID                      EQU 16 * ROMRT_ENTRYSIZE
ROMRT_INFOSENDCHAR                   EQU 17 * ROMRT_ENTRYSIZE
ROMRT_IP_COMPUTECHECKSUM_SOFTWARE    EQU 18 * ROMRT_ENTRYSIZE
ROMRT_DHCPPARSEOPTION                EQU 19 * ROMRT_ENTRYSIZE
ROMRT_DHCPNOTIFY                     EQU 20 * ROMRT_ENTRYSIZE
ROMRT_ROM_TASK_CREATE                EQU 21 * ROMRT_ENTRYSIZE
ROMRT_ROM_TASK_DUPLICATE             EQU 22 * ROMRT_ENTRYSIZE
ROMRT_ROM_TASK_DESTROY               EQU 23 * ROMRT_ENTRYSIZE
ROMRT_ROM_TASK_SWITCH_IN             EQU 24 * ROMRT_ENTRYSIZE
ROMRT_ROM_TASK_SWITCH_OUT            EQU 25 * ROMRT_ENTRYSIZE
ROMRT_OWIP_READCONFIG                EQU 26 * ROMRT_ENTRYSIZE ; not implemented for C compiler, 'same' as SetMACID
ROMRT_SETMACID                       EQU 27 * ROMRT_ENTRYSIZE
ROMRT_UNDEREF                        EQU 28 * ROMRT_ENTRYSIZE
ROMRT_USERIOPOLL                     EQU 29 * ROMRT_ENTRYSIZE
ROMRT_ERRORNOTIFICATION              EQU 30 * ROMRT_ENTRYSIZE

;
; Puts the character to the serial port.  Do not use
; if the serial interrupt is enabled or this will 
; cause an interrupt.
;
; Usage: PUTCHAR 'H'
;        PUTCHAR 'e'
;        PUTCHAR 'l'
;        PUTCHAR 'l'
;        PUTCHAR 'o'
;
; Input: Param CHAR
;
; Output: to serial port
;
; Destroyed: ti bit, sbuf0
;
PUTCHAR MACRO CHAR
     LOCAL pt_lp_top

pt_lp_top:
     jnb  ti, pt_lp_top
     
     ; force it high !!!
     clr  ti
     mov  sbuf0, #CHAR
     ENDM

;
; Helper macro used by PUTHEX.  Takes the binary byte in A
; and returns it as two ASCII characters in b:a.
;
EXPAND MACRO
      LOCAL jmp1, jmp2
      ; turn a into b:a
      push acc
      swap a
      anl  a, #0Fh
      add  a, #030h
      cjne a, #03Ah, $+3
      jc   jmp1
      add  a, #7
jmp1: mov  b, a
      pop  acc
      anl  a, #00Fh
      add  a, #030h
      cjne a, #03Ah, $+3
      jc   jmp2
      add  a, #7
jmp2:
      ENDM


;
; Debug utility to print a byte in hex to the serial port.
;
; Input: Param DIRECT Name of the input byte to be put on 
;        the serial port (use R0_B0 instead of R0)
;
; Output: to serial port
;
; Destroyed: ti bit, sbuf0
;
PUTHEX MACRO DIRECT
         push DIRECT
         push b
         push acc
         mov  a, DIRECT
         EXPAND
         JNB  ti,$
         CLR  ti
         MOV  sbuf0, b
         JNB  ti,$
         CLR  ti
         MOV  sbuf0, a
         pop  acc
         pop  b
         pop  DIRECT
      ENDM



;
; Call the export table function 'FUNCTION' (Use the values ROMXT_*)
; 
; Input: Param FUNCTION The equate for the function to be called.
;
; Output: Any output defined by 'FUNCTION'
;
; Destroyed: Whatever is destroyed by 'FUNCTION'.

;
ROMCALL MACRO FUNCTION
	lcall FUNCTION
        ENDM

;
; Return what is stored in the export table as a pointer, rather than 
; calling it as a funtion.
;
; Input: Param FUNCTION The equate for the function to be called.
;
; Output: r3:r2:r1, the raw pointer stored in the export table
;
; Destroyed: DPTR, A
;
; NOTE: The pointer in r3:r2:r1 will still need to be 'corrected' for 
;       Keil code (if it is going to be used from C code).  This can be
;       done simple by...
; 
;           GETXT_POINTER ROMXT_RAM_TOP
;           inc   r3                             ; fixes the pointer to be used in C code
;
;       Do not use this 'fixed' pointer from assembler code!!!  Use 
;       the original value of r3.
;
GETXT_POINTER  MACRO FUNCTION
      mov   dptr, #FUNCTION
      inc   dptr			      ; Point past the ljmp.
      ;
      ; dptr now points to the X:H:L triple of the pointer
      ;
      GETX
      mov   r3, a
      inc   dptr
      GETX
      mov   r2, a
      inc   dptr
      GETX
      mov   r1, a
      ENDM

;
; Call the redirected function 'FUNCTION' (Use the values ROMRT_*)
; This macro looks up the address of the function defined by 'FUNCTION'
; and puts that address on the stack, thereby 'calling' it.
; 
; Input: Param FUNCTION The equate for the function to be called.
;
; Output: Any output defined by 'FUNCTION'
;
; Destroyed: Whatever is destroyed by 'FUNCTION', plus Register Bank 3
;
; NOTE: Before the function 'FUNCTION' is called, A and DPTR are 
;       preserved (so they can be passed as parameters to 'FUNCTION')
;       but Register Bank 3 is destroyed.
;
ROMREDIRECT  MACRO FUNCTION
      LOCAL return_point
      PUSH_DPTR0
      push  ACC
      mov   dptr, #return_point
      mov   R0_B3, DPL
      mov   R1_B3, DPH
      mov   R2_B3, DPX
      mov   DPX, #LOW((CALL_TABLE_TOP + FUNCTION) Shr 16)
      mov   DPH, #LOW((CALL_TABLE_TOP + FUNCTION) Shr 8)
      mov   DPL, #LOW(CALL_TABLE_TOP + FUNCTION)
      GETX                      ; read high byte
      mov   R5_B3, a
      inc   dptr
      GETX                      ; read mid byte
      mov   R4_B3, a
      inc   dptr
      GETX                      ; read low byte
      mov   R3_B3, a
      pop   ACC                 ; restore acc and dptr
      POP_DPTR0             
      push  R0_B3               ; push low byte of return address
      push  R1_B3
      push  R2_B3               ; push high byte of return address
      push  R3_B3               ; push low byte of target address
      push  R4_B3
      push  R5_B3               ; push high byte of target address
      ret                       ; this is not a ret, it is a call!

return_point:
      ENDM

;
; Install a redirect into the redirect table.
;
; Inputs: r3:r2:r1 The address of the new redirect function.
;         Param OFFSET The ROMRT_* equate for the function to redirect.
;
; Output: None.
;
;  DESTROYED: A, dptr
;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -