Plan 9 from Bell Labs’s /usr/web/sources/contrib/yk/lab/ocptap/utap.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <u.h>
#include <libc.h>
#include <bio.h>

#include "pci.h"

//#define csr32r(c, r)	(*((c)->io+((r)/4)))
//#define csr32w(c, r, v)	(*((c)->io+((r)/4)) = (v))
#define csr32r(c, r)	(*((c)+((r)/4)))
#define csr32w(c, r, v)	(*((c)+((r)/4)) = (v))

static void
reset(void)
{
	Pcidev *p;
	ulong *mmio, *off;
	ulong v;

	p = pcimatch(0, 0x1ad7, 0xa000);
	if(p == nil) {
		print("ocptap: device not found\n");
		return;
	}
	if(p->mem[0].bar == 0){
		print("ocp timecard driver needs a patch to pci.c:/pciscan (add case 0xFF)\n");
		return;
	}
	print("ocptap: timecard detected:");
	pcihinv(p);

	mmio = segattach(0, "ocptap.mmio", 0, p->mem[0].size);
	if(mmio == (void*)-1){
		print("%s: can't attach mmio segment\n", "ocptap");
		return;
	}

	print("ocptap: mmio mapped\n");

	enum {
		SPIflash = 0x00310000,
	};
	v = mmio[(SPIflash)/4];
	//v = csr32r(mmio, SPIflash);
	print("SPIflash\t%.8lux: %.8lux\n", (ulong)SPIflash, v);
	print("ocptap: .\n");

}


void
ocptaplink(void)
{
	reset();
}

void
main(int, char**)
{
	fmtinstall('H', encodefmt);
	Binit(&stdout, 1, OWRITE);

	reset();
	
	exits("");
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].