-
Notifications
You must be signed in to change notification settings - Fork 0
/
swcat.patch
6836 lines (6768 loc) · 195 KB
/
swcat.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/Makefile b/Makefile
index fcb4387..9790880 100644
--- a/Makefile
+++ b/Makefile
@@ -880,7 +880,7 @@ export mod_sign_cmd
ifeq ($(KBUILD_EXTMOD),)
-core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ testcsr/
+core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/
vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
$(core-y) $(core-m) $(drivers-y) $(drivers-m) \
diff --git a/TODO b/TODO
deleted file mode 100644
index 714a0a4..0000000
--- a/TODO
+++ /dev/null
@@ -1 +0,0 @@
-# Add support for polling
diff --git a/arch/alpha/include/asm/mmu_context.h b/arch/alpha/include/asm/mmu_context.h
index 5444778..4c51c053 100644
--- a/arch/alpha/include/asm/mmu_context.h
+++ b/arch/alpha/include/asm/mmu_context.h
@@ -122,7 +122,7 @@ __get_new_mm_context(struct mm_struct *mm, long cpu)
if ((asn & HARDWARE_ASN_MASK) >= MAX_ASN) {
tbiap();
imb();
- next = (asn & ~HARDWARE_ASN_MASK) + ASN_FIRST_VERSION;//start a new ASN version
+ next = (asn & ~HARDWARE_ASN_MASK) + ASN_FIRST_VERSION;
}
cpu_last_asn(cpu) = next;
return next;
diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
index da29974..2f24447f 100644
--- a/arch/alpha/kernel/smp.c
+++ b/arch/alpha/kernel/smp.c
@@ -749,7 +749,6 @@ void
flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
unsigned long addr, int len)
{
- count_vm
struct mm_struct *mm = vma->vm_mm;
if ((vma->vm_flags & VM_EXEC) == 0)
diff --git a/arch/sw_64/Kconfig b/arch/sw_64/Kconfig
index 2820206..2eb63e2 100644
--- a/arch/sw_64/Kconfig
+++ b/arch/sw_64/Kconfig
@@ -484,22 +484,3 @@ source "crypto/Kconfig"
source "lib/Kconfig"
-
-config DEBUG_TLBFLUSH
- bool "Debug tlb flush behavior in sw6a"
- depends on DEBUG_KERNEL
- default y
- ---help---
-
- Enabled now for debug use.
-
- This option allows the user to tune the amount of TLB entries the
- kernel flushes one-by-one instead of doing a full TLB flush. In
- certain situations, the former is cheaper. This is controlled by the
- tlb_flushall_shift knob under /sys/kernel/debug/x86. If you set it
- to -1, the code flushes the whole TLB unconditionally. Otherwise,
- for positive values of it, the kernel will use single TLB entry
- invalidating instructions according to the following formula:
-
- flush_entries <= active_tlb_entries / 2^tlb_flushall_shift
-
diff --git a/arch/sw_64/include/asm/hwrpb.h b/arch/sw_64/include/asm/hwrpb.h
index 352084f..dda5a24 100644
--- a/arch/sw_64/include/asm/hwrpb.h
+++ b/arch/sw_64/include/asm/hwrpb.h
@@ -151,7 +151,7 @@ struct hwrpb_struct {
unsigned long vptb; /* Virtual Page Table Base address */
unsigned long res1;
unsigned long tbhb_offset; /* Translation Buffer Hint Block */
- unsigned long nr_processors; /* Number of per-CPU slots present */
+ unsigned long nr_processors;
unsigned long processor_size;
unsigned long processor_offset;
unsigned long ctb_nr;
diff --git a/arch/sw_64/include/asm/pal.h b/arch/sw_64/include/asm/pal.h
index ff61cd0..5df8167 100644
--- a/arch/sw_64/include/asm/pal.h
+++ b/arch/sw_64/include/asm/pal.h
@@ -32,7 +32,7 @@
#define PAL_wrptbr 0xc
#define PAL_wripir 13
#define PAL_wrfen 43
-#define PAL_wrvcpucb 44
+#define PAL_kvcpucb 44
#define PAL_wrvptptr 45
#define PAL_swpctx 48
#define PAL_tbi 51
@@ -47,7 +47,7 @@
#define PAL_whami 60
#define PAL_retsys 61
#define PAL_rti 63
-#define PAL_testcsr 4
+
#define PAL_sendii 0x3E
#define PAL_callvmm 3
#define PAL_hard_cgid 0x8F
@@ -164,7 +164,7 @@ __CALL_PAL_W1(wrptbr, unsigned long);
__CALL_PAL_RW1(swpipl, unsigned long, unsigned long);
__CALL_PAL_R0(whami, unsigned long);
-__CALL_PAL_R0(wrvcpucb, unsigned long);
+__CALL_PAL_R0(kvcpucb, unsigned long);
__CALL_PAL_R0(sleepen, unsigned long);
__CALL_PAL_R0(mtinten, unsigned long);
__CALL_PAL_W2(wrent, void*, unsigned long);
@@ -176,7 +176,6 @@ __CALL_PAL_W1(wrvptptr, unsigned long);
__CALL_PAL_RW3(sendii, unsigned long, unsigned long, unsigned long, unsigned long);
__CALL_PAL_W1(wrtimer, unsigned long);
__CALL_PAL_R0(hard_cgid, unsigned long);
-__CALL_PAL_R0(testcsr, unsigned long);
/*
* TB routines..
diff --git a/arch/sw_64/include/asm/tlbflush.h b/arch/sw_64/include/asm/tlbflush.h
index ae81434f..c218048 100644
--- a/arch/sw_64/include/asm/tlbflush.h
+++ b/arch/sw_64/include/asm/tlbflush.h
@@ -29,7 +29,6 @@ sw2_flush_tlb_current_page(struct mm_struct * mm,
struct vm_area_struct *vma,
unsigned long addr)
{
- //instruction cache
if (vma->vm_flags & VM_EXEC)
__load_new_mm_context(mm);
else
@@ -114,30 +113,7 @@ static inline void
flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
unsigned long end)
{
-// flush_tlb_mm(vma->vm_mm);
-#if 1
- unsigned long addr;
- struct mm_struct *mm = vma->vm_mm;
- //if((end-start) > MAX_TLB_RANGE) {
- //DTB 64 entries ITB 32 entries
- if((end-start) >(64<< PAGE_SHIFT) || ((end-start)>(32<<PAGE_SHIFT) && vma->vm_flags &VM_EXEC)) {
- flush_tlb_mm(mm);
- return;
- }
-
- start = start >> PAGE_SHIFT;
- end = end >> PAGE_SHIFT;
-
- if (mm == current->active_mm) {
- for(addr=start; addr<end; addr+=1<<(PAGE_SHIFT-13)) {
- flush_tlb_current_page(mm, vma, addr);
- }
- }
- else
- flush_tlb_other(mm);
- printk("flush_tlb_range 1\n");
-#endif
-
+ flush_tlb_mm(vma->vm_mm);
}
#else /* CONFIG_SMP */
diff --git a/arch/sw_64/include/asm/unistd.h b/arch/sw_64/include/asm/unistd.h
index 417ea5f..77efa4f 100644
--- a/arch/sw_64/include/asm/unistd.h
+++ b/arch/sw_64/include/asm/unistd.h
@@ -3,7 +3,7 @@
#include <uapi/asm/unistd.h>
-#define NR_SYSCALLS 515
+#define NR_SYSCALLS 514
#define __ARCH_WANT_OLD_READDIR
#define __ARCH_WANT_STAT64
diff --git a/arch/sw_64/kernel/process.c b/arch/sw_64/kernel/process.c
index 8ead971..e9a6e6d 100644
--- a/arch/sw_64/kernel/process.c
+++ b/arch/sw_64/kernel/process.c
@@ -35,7 +35,6 @@
#include "proto.h"
#include "pci_impl.h"
-#include <linux/cachemask.h>
/*
* Power off function, if any
*/
diff --git a/arch/sw_64/kernel/smp.c b/arch/sw_64/kernel/smp.c
index c539501..e5334ec 100644
--- a/arch/sw_64/kernel/smp.c
+++ b/arch/sw_64/kernel/smp.c
@@ -669,13 +669,11 @@ EXPORT_SYMBOL(smp_imb);
static void ipi_flush_tlb_all(void *ignored)
{
-count_vm_tlb_event(NR_SW_TLB_REMOTE_FLUSH_ALL_RECEIVED);
tbia();
}
void flush_tlb_all(void)
{
-count_vm_tlb_event(NR_SW_TLB_REMOTE_FLUSH_ALL);
/* Although we don't have any data to pass, we do want to
synchronize with the other processors. */
if (on_each_cpu(ipi_flush_tlb_all, NULL, 1)) {
@@ -687,7 +685,6 @@ count_vm_tlb_event(NR_SW_TLB_REMOTE_FLUSH_ALL);
static void ipi_flush_tlb_mm(void *x)
{
-count_vm_tlb_event(NR_SW_TLB_REMOTE_FLUSH_MM_RECEIVED);
struct mm_struct *mm = (struct mm_struct *) x;
if (mm == current->mm)
flush_tlb_current(mm);
@@ -697,7 +694,6 @@ count_vm_tlb_event(NR_SW_TLB_REMOTE_FLUSH_MM_RECEIVED);
void flush_tlb_mm(struct mm_struct *mm)
{
-count_vm_tlb_event(NR_SW_TLB_LOCAL_FLUSH_MM);
preempt_disable();
if (mm == current->mm) {
@@ -720,7 +716,7 @@ count_vm_tlb_event(NR_SW_TLB_LOCAL_FLUSH_MM);
if (smp_call_function(ipi_flush_tlb_mm, mm, 1)) {
printk(KERN_CRIT "flush_tlb_mm: timed out\n");
}
-count_vm_tlb_event(NR_SW_TLB_REMOTE_FLUSH_MM);
+
preempt_enable();
}
EXPORT_SYMBOL(flush_tlb_mm);
@@ -736,7 +732,6 @@ static void ipi_flush_tlb_page(void *x)
struct flush_tlb_page_struct *data = (struct flush_tlb_page_struct *)x;
struct mm_struct * mm = data->mm;
- count_vm_tlb_event(NR_SW_TLB_REMOTE_FLUSH_ONE_RECEIVED);
if (mm == current->mm)
flush_tlb_current_page(mm, data->vma, data->addr);
else
@@ -750,26 +745,23 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
struct mm_struct *mm = vma->vm_mm;
preempt_disable();
- //current->mm means
- count_vm_tlb_event(NR_SW_TLB_LOCAL_FLUSH_ONE);
+
if (mm == current->mm) {
- //start working on new ASN version for ITB || directly flush DTB
flush_tlb_current_page(mm, vma, addr);
if (atomic_read(&mm->mm_users) == 1) {
- int cpu;
- int this_cpu = smp_processor_id();
+ int cpu, this_cpu = smp_processor_id();
for (cpu = 0; cpu < NR_CPUS; cpu++) {
if (!cpu_online(cpu) || cpu == this_cpu)
continue;
if (mm->context[cpu])
- mm->context[cpu] = 0;//clear the trace of this mm on other core?
+ mm->context[cpu] = 0;
}
preempt_enable();
return;
}
}
else
- flush_tlb_other(mm);//clear the trace of mm on this core
+ flush_tlb_other(mm);
data.vma = vma;
data.mm = mm;
@@ -786,41 +778,13 @@ EXPORT_SYMBOL(flush_tlb_page);
void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end)
{
/* On the SW we always flush the whole user tlb. */
-// flush_tlb_mm(vma->vm_mm);
- count_vm_tlb_event(NR_SW_TLB_LOCAL_FLUSH_RANGE);
-#if 1
- unsigned long addr;
- struct mm_struct *mm = vma->vm_mm;
-
- //DTB 64 entries or entire ITB
- if((end-start) >(64<< PAGE_SHIFT) || (vma->vm_flags &VM_EXEC)) {
- flush_tlb_mm(mm);
- return;
- }
-
- //loop and do flush_tlb_page
- start = start >> PAGE_SHIFT;
- end = end >> PAGE_SHIFT;
-
- if (mm == current->mm) {
- for(addr=start; addr<end; addr+=1<<(PAGE_SHIFT-13)) {
- flush_tlb_page(vma,addr);
- }
- }
- else {
- preempt_disable();
- flush_tlb_other(mm);
- preempt_enable();
- }
-
-#endif
+ flush_tlb_mm(vma->vm_mm);
}
EXPORT_SYMBOL(flush_tlb_range);
static void ipi_flush_icache_page(void *x)
{
struct mm_struct *mm = (struct mm_struct *) x;
- count_vm_tlb_event(NR_SW_ICACHE_FLUSH_ONE);
if (mm == current->mm)
__load_new_mm_context(mm);
else
@@ -831,7 +795,7 @@ void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
unsigned long addr, int len)
{
struct mm_struct *mm = vma->vm_mm;
- count_vm_tlb_event(NR_SW_ICACHE_FLUSH_USR_RANGE);
+
if ((vma->vm_flags & VM_EXEC) == 0)
return;
diff --git a/arch/sw_64/kernel/systbls.S b/arch/sw_64/kernel/systbls.S
index e7abca1..2c2e7e5 100644
--- a/arch/sw_64/kernel/systbls.S
+++ b/arch/sw_64/kernel/systbls.S
@@ -532,7 +532,8 @@ sys_call_table:
.quad sys_getrandom
.quad sys_memfd_create
.quad sys_execveat
- .quad sys_testcsr /* 514 */
+
+
.size sys_call_table, . - sys_call_table
.type sys_call_table, @object
diff --git a/arch/sw_64/mm/numa.c b/arch/sw_64/mm/numa.c
index d147606..720ec5f 100644
--- a/arch/sw_64/mm/numa.c
+++ b/arch/sw_64/mm/numa.c
@@ -101,17 +101,12 @@ setup_memory_node(int nid, void *kernel_end)
printk(" memcluster %2d, usage %1lx, start %8lu, end %8lu\n",
i, cluster->usage, cluster->start_pfn,
cluster->start_pfn + cluster->numpages);
- printk(" start %8lu, node_pfn_start %8lu, end %8lu, node_pfn_end %8lu\n",
- start,node_pfn_start,
- end,node_pfn_end);
-
if (start < node_pfn_start)
start = node_pfn_start;
if (end > node_pfn_end)
end = node_pfn_end;
- printk("0 node_min_pfn is %8lu, start is %8lu\n",node_min_pfn,start );
if (start < node_min_pfn)
node_min_pfn = start;
if (end > node_max_pfn)
@@ -129,7 +124,6 @@ setup_memory_node(int nid, void *kernel_end)
node_max_pfn = mem_size_limit;
}
- printk("1 node_min_pfn is %8lu,node_datasz is %lu size of zone is %d\n",node_min_pfn,node_datasz, sizeof(struct zone));
if (node_min_pfn >= node_max_pfn)
return;
@@ -161,8 +155,6 @@ setup_memory_node(int nid, void *kernel_end)
start_kernel_pfn = PFN_DOWN(__pa(KERNEL_START));
end_kernel_pfn = PFN_UP(virt_to_phys(kernel_end));
bootmap_start = -1;
- printk(" nid is %d, start_kernel_pfn is %d, end_kernel_pfn is %d\n",nid,start_kernel_pfn,end_kernel_pfn );
- printk(" node_min_pfn is %8lu, node_max_pfn is %8lu\n",node_min_pfn,node_max_pfn );
if (!nid && (node_max_pfn < end_kernel_pfn || node_min_pfn > start_kernel_pfn))
panic("kernel loaded out of ram");
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index cf04525..537d7f3 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -56,4 +56,3 @@ obj-$(CONFIG_GENWQE) += genwqe/
obj-$(CONFIG_ECHO) += echo/
obj-$(CONFIG_VEXPRESS_SYSCFG) += vexpress-syscfg.o
obj-$(CONFIG_CXL_BASE) += cxl/
-obj-y += zgl/
diff --git a/drivers/misc/zgl/Makefile b/drivers/misc/zgl/Makefile
deleted file mode 100644
index 701ae65..0000000
--- a/drivers/misc/zgl/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-#obj-m := chrdev.o zglchar.o
-obj-m := zglchar.o
-KERNELDIR ?= /home/zgl/linux-4.4-sw.git
-PWD := $(shell pwd)
-
-all:
- $(MAKE) CROSS_COMPILE=sw_64sw2-unknown-linux-gnu- ARCH=sw_64 -C $(KERNELDIR) M=$(PWD) modules
-
-clean:
- rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
-
diff --git a/drivers/misc/zgl/chrdev.c b/drivers/misc/zgl/chrdev.c
deleted file mode 100644
index 73b538e..0000000
--- a/drivers/misc/zgl/chrdev.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
-* Copyright (c) nobody
-*
-* All rights reserved.
-* This program is free to use, but the ban on selling behavior.
-* Modify the program must keep all the original text description.
-* Email: [email protected]
-*******************************************************************************/
-
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/init.h>
-#include <linux/cdev.h>
-#include <linux/fs.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <asm/uaccess.h>
-
-#define MY_MAJOR 200
-#define MY_MINOR 0
-#define MY_DEV_COUNT 2
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("zgl");
-MODULE_DESCRIPTION("No idea");
-
-
-int chardev_init(void);
-void chardev_exit(void);
-static int device_open(struct inode *, struct file *);
-static int device_close(struct inode *, struct file *);
-static ssize_t device_read(struct file *, char *, size_t, loff_t *);
-static ssize_t device_write(struct file *, const char *, size_t, loff_t *);
-static loff_t device_lseek(struct file *file, loff_t offset, int orig);
-
-/*new code*/
-#define BUFFER_SIZE 1024
-static char device_buffer[BUFFER_SIZE];
-struct semaphore sem;
-struct cdev *mcdev; /*this is the name of my char driver that i will be registering*/
-int major_number; /* will store the major number extracted by dev_t*/
-int ret; /*used to return values*/
-dev_t dev_num; /*will hold the major number that the kernel gives*/
-
-#define DEVICENAME "zgl"
-
-/*inode reffers to the actual file on disk*/
-static int device_open(struct inode *inode, struct file *filp) {
- if(down_interruptible(&sem) != 0) {
- printk(KERN_ALERT "zgl : the device has been opened by some other device, unable to open lock\n");
- return -1;
- }
- //buff_rptr = buff_wptr = device_buffer;
- printk(KERN_INFO "zgl : device opened succesfully\n");
- return 0;
-}
-
-static ssize_t device_read(struct file *fp, char *buff, size_t length, loff_t *ppos) {
- int maxbytes; /*maximum bytes that can be read from ppos to BUFFER_SIZE*/
- int bytes_to_read; /* gives the number of bytes to read*/
- int bytes_read;/*number of bytes actually read*/
- maxbytes = BUFFER_SIZE - *ppos;
- if(maxbytes > length)
- bytes_to_read = length;
- else
- bytes_to_read = maxbytes;
- if(bytes_to_read == 0)
- printk(KERN_INFO "zgl : Reached the end of the device\n");
- bytes_read = bytes_to_read - copy_to_user(buff, device_buffer + *ppos, bytes_to_read);
- printk(KERN_INFO "zgl : device has been read %d\n",bytes_read);
- *ppos += bytes_read;
- printk(KERN_INFO "zgl : device has been read\n");
- return bytes_read;
-}
-
-static ssize_t device_write(struct file *fp, const char *buff, size_t length, loff_t *ppos) {
- int maxbytes; /*maximum bytes that can be read from ppos to BUFFER_SIZE*/
- int bytes_to_write; /* gives the number of bytes to write*/
- int bytes_writen;/*number of bytes actually writen*/
- maxbytes = BUFFER_SIZE - *ppos;
- if(maxbytes > length)
- bytes_to_write = length;
- else
- bytes_to_write = maxbytes;
- bytes_writen = bytes_to_write - copy_from_user(device_buffer + *ppos, buff, bytes_to_write);
- printk(KERN_INFO "zgl : device has been written %d\n",bytes_writen);
- *ppos += bytes_writen;
- printk(KERN_INFO "zgl : device has been written\n");
- return bytes_writen;
-}
-
-static loff_t device_lseek(struct file *file, loff_t offset, int orig) {
- loff_t new_pos = 0;
- printk(KERN_INFO "zgl : lseek function in work\n");
- switch(orig) {
- case 0 : /*seek set*/
- new_pos = offset;
- break;
- case 1 : /*seek cur*/
- new_pos = file->f_pos + offset;
- break;
- case 2 : /*seek end*/
- new_pos = BUFFER_SIZE - offset;
- break;
- }
- if(new_pos > BUFFER_SIZE)
- new_pos = BUFFER_SIZE;
- if(new_pos < 0)
- new_pos = 0;
- file->f_pos = new_pos;
- return new_pos;
-}
-
-static int device_close(struct inode *inode, struct file *filp) {
- up(&sem);
- printk(KERN_INFO "zgl : device has been closed\n");
- return ret;
-}
-
-struct file_operations fops = { /* these are the file operations provided by our driver */
- .owner = THIS_MODULE, /*prevents unloading when operations are in use*/
- .open = device_open, /*to open the device*/
- .write = device_write, /*to write to the device*/
- .read = device_read, /*to read the device*/
- .release = device_close, /*to close the device*/
- .llseek = device_lseek
-};
-
-
-int chardev_init(void)
-{
- /* we will get the major number dynamically this is recommended please read ldd3*/
- ret = alloc_chrdev_region(&dev_num,0,1,DEVICENAME);
- if(ret < 0) {
- printk(KERN_ALERT " zgl : failed to allocate major number\n");
- return ret;
- }
- else
- printk(KERN_INFO " zgl : mjor number allocated succesful\n");
- major_number = MAJOR(dev_num);
- printk(KERN_INFO "zgl : major number of our device is %d\n",major_number);
- printk(KERN_INFO "zgl : to use mknod /dev/%s c %d 0\n",DEVICENAME,major_number);
-
- mcdev = cdev_alloc(); /*create, allocate and initialize our cdev structure*/
- mcdev->ops = &fops; /*fops stand for our file operations*/
- mcdev->owner = THIS_MODULE;
-
- /*we have created and initialized our cdev structure now we need to add it to the kernel*/
- ret = cdev_add(mcdev,dev_num,1);
- if(ret < 0) {
- printk(KERN_ALERT "zgl : device adding to the kerknel failed\n");
- return ret;
- }
- else
- printk(KERN_INFO "zgl : device additin to the kernel succesful\n");
- sema_init(&sem,1); /* initial value to one*/
-
- return 0;
-}
-
-void chardev_exit(void)
-{
- cdev_del(mcdev); /*removing the structure that we added previously*/
- printk(KERN_INFO " zgl : removed the mcdev from kernel\n");
-
- unregister_chrdev_region(dev_num,1);
- printk(KERN_INFO "zgl : unregistered the device numbers\n");
- printk(KERN_ALERT " zgl : character driver is exiting\n");
-}
-module_init(chardev_init);
-module_exit(chardev_exit);
-
diff --git a/drivers/misc/zgl/load.sh b/drivers/misc/zgl/load.sh
deleted file mode 100644
index 8d88036..0000000
--- a/drivers/misc/zgl/load.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-sudo insmod zglchar.ko
-sudo mknod /dev/zglchar c 251 0
-sudo chmod 777 /dev/zglchar
diff --git a/drivers/misc/zgl/mk b/drivers/misc/zgl/mk
deleted file mode 100755
index 8951919..0000000
--- a/drivers/misc/zgl/mk
+++ /dev/null
@@ -1,2 +0,0 @@
-export PATH=/usr/sw/swgcc511-cross-6A/usr/bin:$PATH
-make -j24
diff --git a/drivers/misc/zgl/unload.sh b/drivers/misc/zgl/unload.sh
deleted file mode 100644
index 7b2606d..0000000
--- a/drivers/misc/zgl/unload.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-sudo rmmod zglchar
-sudo rm /dev/zglchar
diff --git a/drivers/misc/zgl/userspaceAccess.c b/drivers/misc/zgl/userspaceAccess.c
deleted file mode 100644
index 3d47eae..0000000
--- a/drivers/misc/zgl/userspaceAccess.c
+++ /dev/null
@@ -1,146 +0,0 @@
-#include<stdio.h>
-#include<fcntl.h>
-#include<string.h>
-#include<malloc.h>
-
-#define DEVICE "/dev/zglchar"
-int debug = 1, fd = 0;
-
-int write_device() {
- int write_length = 0;
- ssize_t ret;
- char *data = (char *)malloc(1024 * sizeof(char));
- printf("please enter the data to write into device\n");
- scanf(" %[^\n]",data); /* a space added after"so that it reads white space, %[^\n] is addeed so that it takes input until new line*/
- write_length = strlen(data);
- if(debug)printf("the length of dat written = %d\n",write_length);
- ret = write(fd, data, write_length);
- if(ret == -1)
- printf("writting failed\n");
- else
- printf("writting success\n");
- if(debug)fflush(stdout);/*not to miss any log*/
- free(data);
-return 0;
-}
-
-int read_device() {
- int read_length = 0;
- ssize_t ret;
- char *data = (char *)malloc(1024 * sizeof(char));
- printf("enter the length of the buffer to read\n");
- scanf("%d",&read_length);
- if(debug)printf("the read length selected is %d\n",read_length);
- memset(data,0,sizeof(data));
- data[0] = '\0';
- ret = read(fd,data,read_length);
- printf("DEVICE_READ : %s\n",data);
- if(ret == -1)
- printf("reading failed\n");
- else
- printf("reading success\n");
- if(debug)fflush(stdout);/*not to miss any log*/
- free(data);
-return 0;
-}
-
-int lseek_device() {
- int lseek_offset = 0,seek_value = 0;
- int counter = 0; /* to check if function called multiple times or loop*/
- counter++;
- printf("counter value = %d\n",counter);
- printf("enter the seek offset\n");
- scanf("%d",&lseek_offset);
- if(debug) printf("seek_offset selected is %d\n",lseek_offset);
- printf("1 for SEEK_SET, 2 for SEEK_CUR and 3 for SEEK_END\n");
- scanf("%d", &seek_value);
- printf("seek value = %d\n", seek_value);
- switch(seek_value) {
- case 1: lseek(fd,lseek_offset,SEEK_SET);
- return 0;
- break;
- case 2: lseek(fd,lseek_offset,SEEK_CUR);
- return 0;
- break;
- case 3: lseek(fd,lseek_offset,SEEK_END);
- return 0;
- break;
- default : printf("unknown option selected, please enter right one\n");
- break;
- }
- /*if(seek_value == 1) {
- printf("seek value = %d\n", seek_value);
- lseek(fd,lseek_offset,SEEK_SET);
- return 0;
- }
- if(seek_value == 2) {
- lseek(fd,lseek_offset,SEEK_CUR);
- return 0;
- }
- if(seek_value == 3) {
- lseek(fd,lseek_offset,SEEK_END);
- return 0;
- }*/
- if(debug)fflush(stdout);/*not to miss any log*/
-return 0;
-}
-
-int lseek_write() {
- lseek_device();
- write_device();
-return 0;
-}
-
-int lseek_read() {
- lseek_device();
- read_device();
-return 0;
-}
-
-int main()
-{
- int value = 0;
- if(access(DEVICE, F_OK) == -1) {
- printf("module %s not loaded\n",DEVICE);
- return 0;
- }
- else
- printf("module %s loaded, will be used\n",DEVICE);
-
- while(1) {
- printf("\t\tplease enter 1 to write\n \
- 2 to read\n \
- 3 to lseek and write\
- 4 to lseek and read\n");
- scanf("%d",&value);
- switch(value) {
- case 1 :printf("write option selected\n");
- fd = open(DEVICE, O_RDWR);
- write_device();
- close(fd); /*closing the device*/
- break;
- case 2 :printf("read option selected\n");
- /* dont know why but i am suppoesed to open it for writing and close it, i cant keep open and read.
- its not working, need to sort out why is that so */
- fd = open(DEVICE, O_RDWR);
- read_device();
- close(fd); /*closing the device*/
- break;
- case 3 :printf("lseek option selected\n");
- fd = open(DEVICE, O_RDWR);
- lseek_write();
- close(fd); /*closing the device*/
- break;
- case 4 :printf("lseek option selected\n");
- fd = open(DEVICE, O_RDWR);
- lseek_read();
- close(fd); /*closing the device*/
- break;
- default : printf("unknown option selected, please enter right one\n");
- break;
- }
- }
- return 0;
-}
-
-
diff --git a/drivers/misc/zgl/zglchar.c b/drivers/misc/zgl/zglchar.c
deleted file mode 100644
index 17eb5a9..0000000
--- a/drivers/misc/zgl/zglchar.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- * @file zglchar.c
- * @author zgl
- * @Simple module reads and write from userspace
- */
-#include <linux/init.h> // Macros used to mark up functions e.g. __init __exit
-#include <linux/module.h> // Core header for loading LKMs into the kernel
-#include <linux/device.h> // Header to support the kernel Driver Model
-#include <linux/kernel.h> // Contains types, macros, functions for the kernel
-#include <linux/fs.h> // Header for the Linux file system support
-#include <linux/uaccess.h> // Required for the copy to user function
-#define DEVICE_NAME "zglchar" ///< The device will appear at /dev/zglchar using this value
-#define CLASS_NAME "zgl" ///< The device class -- this is a character device driver
-
-MODULE_LICENSE("GPL"); ///< The license type -- this affects available functionality
-MODULE_AUTHOR("zgl"); ///< The author -- visible when you use modinfo
-MODULE_DESCRIPTION("A simple Linux char driver for the xxx"); ///< The description -- see modinfo
-MODULE_VERSION("0.1"); ///< A version number to inform users
-
-static int majorNumber; ///< Stores the device number -- determined automatically
-static char message[256] = {0}; ///< Memory for the string that is passed from userspace
-static short size_of_message; ///< Used to remember the size of the string stored
-static int numberOpens = 0; ///< Counts the number of times the device is opened
-static struct class* zglcharClass = NULL; ///< The device-driver class struct pointer
-static struct device* zglcharDevice = NULL; ///< The device-driver device struct pointer
-
-// The prototype functions for the character driver -- must come before the struct definition
-static int dev_open(struct inode *, struct file *);
-static int dev_release(struct inode *, struct file *);
-static ssize_t dev_read(struct file *, char *, size_t, loff_t *);
-static ssize_t dev_write(struct file *, const char *, size_t, loff_t *);
-
-/** @brief Devices are represented as file structure in the kernel. The file_operations structure from
- * /linux/fs.h lists the callback functions that you wish to associated with your file operations
- * using a C99 syntax structure. char devices usually implement open, read, write and release calls
- */
-static struct file_operations fops =
-{
- .open = dev_open,
- .read = dev_read,
- .write = dev_write,
- .release = dev_release,
-};
-
-/** @brief The LKM initialization function
- * The static keyword restricts the visibility of the function to within this C file. The __init
- * macro means that for a built-in driver (not a LKM) the function is only used at initialization
- * time and that it can be discarded and its memory freed up after that point.
- * @return returns 0 if successful
- */
-static int __init zglchar_init(void){
- printk(KERN_INFO "zglchar: Initializing the zglchar LKM\n");
-
- // Try to dynamically allocate a major number for the device -- more difficult but worth it
- majorNumber = register_chrdev(0, DEVICE_NAME, &fops);
- if (majorNumber<0){
- printk(KERN_ALERT "zglchar failed to register a major number\n");
- return majorNumber;
- }
- printk(KERN_INFO "zglchar: registered correctly with major number %d\n", majorNumber);
-
- // Register the device class
- zglcharClass = class_create(THIS_MODULE, CLASS_NAME);
- if (IS_ERR(zglcharClass)){ // Check for error and clean up if there is
- unregister_chrdev(majorNumber, DEVICE_NAME);
- printk(KERN_ALERT "Failed to register device class\n");
- return PTR_ERR(zglcharClass); // Correct way to return an error on a pointer
- }
- printk(KERN_INFO "zglchar: device class registered correctly\n");
-
- // Register the device driver
- zglcharDevice = device_create(zglcharClass, NULL, MKDEV(majorNumber, 0), NULL, DEVICE_NAME);
- if (IS_ERR(zglcharDevice)){ // Clean up if there is an error
- class_destroy(zglcharClass); // Repeated code but the alternative is goto statements
- unregister_chrdev(majorNumber, DEVICE_NAME);
- printk(KERN_ALERT "Failed to create the device\n");
- return PTR_ERR(zglcharDevice);
- }
- printk(KERN_INFO "zglchar: device class created correctly\n"); // Made it! device was initialized
- return 0;
-}
-
-/** @brief The LKM cleanup function
- * Similar to the initialization function, it is static. The __exit macro notifies that if this
- * code is used for a built-in driver (not a LKM) that this function is not required.
- */
-static void __exit zglchar_exit(void){
- device_destroy(zglcharClass, MKDEV(majorNumber, 0)); // remove the device
- class_unregister(zglcharClass); // unregister the device class
- class_destroy(zglcharClass); // remove the device class
- unregister_chrdev(majorNumber, DEVICE_NAME); // unregister the major number
- printk(KERN_INFO "zglchar: Goodbye from the LKM!\n");
-}
-
-/** @brief The device open function that is called each time the device is opened
- * This will only increment the numberOpens counter in this case.
- * @param inodep A pointer to an inode object (defined in linux/fs.h)
- * @param filep A pointer to a file object (defined in linux/fs.h)
- */
-static int dev_open(struct inode *inodep, struct file *filep){
- numberOpens++;
- printk(KERN_INFO "zglchar: Device has been opened %d time(s)\n", numberOpens);
- return 0;
-}
-
-/** @brief This function is called whenever device is being read from user space i.e. data is
- * being sent from the device to the user. In this case is uses the copy_to_user() function to
- * send the buffer string to the user and captures any errors.
- * @param filep A pointer to a file object (defined in linux/fs.h)
- * @param buffer The pointer to the buffer to which this function writes the data
- * @param len The length of the b
- * @param offset The offset if required
- */
-static ssize_t dev_read(struct file *filep, char *buffer, size_t len, loff_t *offset){
- int error_count = 0;
- // copy_to_user has the format ( * to, *from, size) and returns 0 on success
- error_count = copy_to_user(buffer, message, size_of_message);
-
- if (error_count==0){ // if true then have success
- printk(KERN_INFO "zglchar: Sent %d characters to the user\n", size_of_message);
- return (size_of_message=0); // clear the position to the start and return 0
- }
- else {
- printk(KERN_INFO "zglchar: Failed to send %d characters to the user\n", error_count);
- return -EFAULT; // Failed -- return a bad address message (i.e. -14)
- }
-}
-
-/** @brief This function is called whenever the device is being written to from user space i.e.
- * data is sent to the device from the user. The data is copied to the message[] array in this
- * LKM using the sprintf() function along with the length of the string.
- * @param filep A pointer to a file object
- * @param buffer The buffer to that contains the string to write to the device
- * @param len The length of the array of data that is being passed in the const char buffer
- * @param offset The offset if required
- */
-static ssize_t dev_write(struct file *filep, const char *buffer, size_t len, loff_t *offset){
- sprintf(message, "%s(%zu letters)", buffer, len); // appending received string with its length
- size_of_message = strlen(message); // store the length of the stored message
- printk(KERN_INFO "zglchar: Received %zu characters from the user\n", len);
- return len;
-}
-
-/** @brief The device release function that is called whenever the device is closed/released by
- * the userspace program
- * @param inodep A pointer to an inode object (defined in linux/fs.h)
- * @param filep A pointer to a file object (defined in linux/fs.h)
- */
-static int dev_release(struct inode *inodep, struct file *filep){
- printk(KERN_INFO "zglchar: Device successfully closed\n");
- return 0;
-}
-
-/** @brief A module must use the module_init() module_exit() macros from linux/init.h, which
- * identify the initialization function at insertion time and the cleanup function (as
- * listed above)
- */
-module_init(zglchar_init);
-module_exit(zglchar_exit);
-
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 720a70f..e8bbf6c 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -134,12 +134,6 @@ struct pid_entry {
NOD(NAME, (S_IFREG|(MODE)), \
NULL, &proc_single_file_operations, \
{ .proc_show = show } )
-/* page color */
-#define REG_PAGE_COLOR(NAME,MODE) \
- NOD(NAME,(S_IFREG|MODE),NULL, \
- &proc_page_color_operations, {})
-
-
/*
* Count the number of hardlinks for the pid_entry table, excluding the .
@@ -947,112 +941,6 @@ static const struct file_operations proc_mem_operations = {
.release = mem_release,
};
-#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
-/* page color */
-static ssize_t proc_page_color_read(struct file * file, char __user * buf, size_t count, loff_t *ppos)
-{
- //struct inode * inode = file->f_dentry->d_inode;
- struct inode * inode = file_inode(file);
- char* page;
- ssize_t len = 0;
- struct task_struct *task = get_proc_task(inode);
- int i;
-
- if( *ppos >= 10 )
- return 0;
-
- if (count > PROC_BLOCK_SIZE)
- count = PROC_BLOCK_SIZE;
-
- if (!(page = (char*)__get_free_page(GFP_KERNEL)))
- return -ENOMEM;
-
- //pagecolor_printk("[PAGE_COLOR] proc_page_color_read\n");
- len += sprintf(page + len, "%s: ", "alloc_in_order");
- for(i=0; i<NUM_CACHE_COLOR; i++)
- len += sprintf(page + len, "%8lu ", task->page_alloc_in_order[i]);
- len += sprintf(page + len, "%s", "\n");
-
- len += sprintf(page + len, "%s: ", "free_in_order");
- for(i=0; i<NUM_CACHE_COLOR; i++)
- len += sprintf(page + len, "%8lu ", task->page_free_in_order[i]);
- len += sprintf(page + len, "%s", "\n");
-
- len += sprintf(page + len, "%s: ", "======cat color number======");
- for(i=0; i<NUM_CACHE_COLOR; i++)
- len += sprintf(page + len, "%d ", i);
- len += sprintf(page + len, "%s", "\n");
-
- len += sprintf(page + len, "%s: ", "alloc_in_color");
- for(i=0; i<NUM_CACHE_COLOR; i++)
- len += sprintf(page + len, "%8lu ", task->page_alloc_in_color[i]);
- len += sprintf(page + len, "%s", "\n");
-
- len += sprintf(page + len, "%s: ", "free_in_color");
- for(i=0; i<NUM_CACHE_COLOR; i++)
- len += sprintf(page + len, "%8lu ", task->page_free_in_color[i]);
- len += sprintf(page + len, "%s", "\n\n");
-
-
- len += sprintf(page + len, "%s: ", "cache_color_mask");