summaryrefslogtreecommitdiff
path: root/sys/src/9/port/segment.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2016-03-27 20:57:01 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2016-03-27 20:57:01 +0200
commit04c3a6f66e3b895a087124ed415f01e23e21ee10 (patch)
tree7efd53b8b1d4cc461401ef5a2ecb2fdba13b70f8 /sys/src/9/port/segment.c
parentbf2195b88c9c1483d97cb4578f81467cad73c39e (diff)
zynq: introduce SG_FAULT to prevent access to AXI segment while PL is not ready
access to the axi segment hangs the machine when the fpga is not programmed yet. to prevent access, we introduce a new SG_FAULT flag, that when set on the Segment.type or Physseg.attr, causes the fault handler to immidiately return with an error (as if the segment would not be mapped). during programming, we temporarily set the SG_FAULT flag on the axi physseg, flush all processes tlb's that have the segment mapped and when programming is done, we clear the flag again.
Diffstat (limited to 'sys/src/9/port/segment.c')
-rw-r--r--sys/src/9/port/segment.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/sys/src/9/port/segment.c b/sys/src/9/port/segment.c
index e9e8959df..e257e47b3 100644
--- a/sys/src/9/port/segment.c
+++ b/sys/src/9/port/segment.c
@@ -551,7 +551,7 @@ isoverlap(Proc *p, uintptr va, uintptr len)
return nil;
}
-int
+Physseg*
addphysseg(Physseg* new)
{
Physseg *ps;
@@ -564,34 +564,29 @@ addphysseg(Physseg* new)
for(ps = physseg; ps->name; ps++){
if(strcmp(ps->name, new->name) == 0){
unlock(&physseglock);
- return -1;
+ return nil;
}
}
if(ps-physseg >= nelem(physseg)-2){
unlock(&physseglock);
- return -1;
+ return nil;
}
*ps = *new;
unlock(&physseglock);
- return 0;
+ return ps;
}
-int
-isphysseg(char *name)
+Physseg*
+findphysseg(char *name)
{
Physseg *ps;
- int rv = 0;
- lock(&physseglock);
- for(ps = physseg; ps->name; ps++){
- if(strcmp(ps->name, name) == 0){
- rv = 1;
- break;
- }
- }
- unlock(&physseglock);
- return rv;
+ for(ps = physseg; ps->name; ps++)
+ if(strcmp(ps->name, name) == 0)
+ return ps;
+
+ return nil;
}
uintptr
@@ -654,12 +649,10 @@ segattach(Proc *p, ulong attr, char *name, uintptr va, uintptr len)
if(isoverlap(p, va, len) != nil)
error(Esoverlap);
- for(ps = physseg; ps->name; ps++)
- if(strcmp(name, ps->name) == 0)
- goto found;
+ ps = findphysseg(name);
+ if(ps == nil)
+ error(Ebadarg);
- error(Ebadarg);
-found:
if(len > ps->size)
error(Enovmem);