1 \ *****************************************************************************
2 \ * Copyright (c) 2004, 2008 IBM Corporation
3 \ * All rights reserved.
4 \ * This program and the accompanying materials
5 \ * are made available under the terms of the BSD License
6 \ * which accompanies this distribution, and is available at
7 \ * http://www.opensource.org/licenses/bsd-license.php
10 \ * IBM Corporation - initial implementation
11 \ ****************************************************************************/
16 new-device 500 1 set-unit
18 s" tpm" 2dup device-name device-type
20 s" AT97SC3201" compatible
22 \ 2 bytes of ISA I/O space
23 my-unit encode-int rot encode-int+ 2 encode-int+ s" reg" property
26 : tpm@ >tpm 4f io-c@ ;
27 : tpm! >tpm 4f io-c! ;
29 : dump-tpm 11 0 DO cr i 2 .r space i tpm@ 2 0.r LOOP ;
31 my-address wbsplit 9 tpm! 8 tpm! \ set base address
32 0 a tpm! \ disable serint
34 \ Now we need to execute TPM_Startup.
38 0 c, 0 c, 0 c, 99 c, \ TPM_ORD_Startup
39 0 c, 1 c, \ TCPA_ST_CLEAR
41 : send ( addr len -- ) bounds ?DO i c@ 500 io-c! LOOP ;
42 : wait-for-ready ( -- ) BEGIN 501 io-c@ 3 and 2 = UNTIL ;
45 500 io-c@ 2 0.r 500 io-c@ 2 0.r space
46 500 io-c@ 500 io-c@ 500 io-c@ 500 io-c@
47 bljoin lbflip 6 - dup 8 0.r space 0
52 500 io-c@ drop 500 io-c@ drop
53 500 io-c@ 500 io-c@ 500 io-c@ 500 io-c@
55 ?DO 500 io-c@ drop LOOP
58 startup-cmd c send wait-for-ready recv